From 5a818b6f4191bc860d6d4853ccabbed05622e05c Mon Sep 17 00:00:00 2001 From: Sara Ahmadi Date: Tue, 17 Nov 2026 14:02:05 +0100 Subject: [PATCH 1/2] feat(graph): add logging and tracing to the single-permission GET endpoints Assisted-by: Claude Code:claude-opus-5-5 --- .../service/v0/api_driveitem_permissions.go | 23 +++- .../v0/api_driveitem_permissions_test.go | 113 ++++++++++++++++++ 2 files changed, 132 insertions(+), 4 deletions(-) diff --git a/services/graph/pkg/service/v0/api_driveitem_permissions.go b/services/graph/pkg/service/v0/api_driveitem_permissions.go index 38fc483f45..4d8771b393 100644 --- a/services/graph/pkg/service/v0/api_driveitem_permissions.go +++ b/services/graph/pkg/service/v0/api_driveitem_permissions.go @@ -900,7 +900,12 @@ func (s DriveItemPermissionsService) UpdateSpaceRootPermission(ctx context.Conte // GetPermission returns a single permission of a drive item. // It reuses ListPermissions, so only permissions visible in the listing of the item can be retrieved. -func (s DriveItemPermissionsService) GetPermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string) (libregraph.Permission, error) { +func (s DriveItemPermissionsService) GetPermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string) (_ libregraph.Permission, err error) { + ctx, span := s.tp.Tracer(_tracerName).Start(ctx, "GetPermission") + defer func() { endSpan(span, err) }() + logger := s.logger.SubloggerWithRequestID(ctx) + + // ListPermissions logs its own failures collection, err := s.ListPermissions(ctx, itemID, ListPermissionsQueryOptions{}) if err != nil { return libregraph.Permission{}, err @@ -912,23 +917,33 @@ func (s DriveItemPermissionsService) GetPermission(ctx context.Context, itemID * } } + logger.Debug().Str(_logKeyItemID, storagespace.FormatResourceID(itemID)).Str(_logKeyPermissionID, permissionID).Msg("permission not found") return libregraph.Permission{}, errorcode.New(errorcode.ItemNotFound, "permission not found") } // GetSpaceRootPermission returns a single permission on the root item of a project space -func (s DriveItemPermissionsService) GetSpaceRootPermission(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string) (libregraph.Permission, error) { +func (s DriveItemPermissionsService) GetSpaceRootPermission(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string) (_ libregraph.Permission, err error) { + ctx, span := s.tp.Tracer(_tracerName).Start(ctx, "GetSpaceRootPermission") + defer func() { endSpan(span, err) }() + logger := s.logger.SubloggerWithRequestID(ctx) + gatewayClient, err := s.gatewaySelector.Next() if err != nil { + errorEvent(&logger, err).Str(_logKeyDriveID, storagespace.FormatResourceID(driveID)).Str(_logKeyPermissionID, permissionID).Msg("could not select next gateway client") return libregraph.Permission{}, err } space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient) if err != nil { - return libregraph.Permission{}, errorcode.FromUtilsStatusCodeError(err) + spaceErr := errorcode.FromUtilsStatusCodeError(err) + errorEvent(&logger, spaceErr).Str(_logKeyDriveID, storagespace.FormatResourceID(driveID)).Str(_logKeyPermissionID, permissionID).Msg("could not get space") + return libregraph.Permission{}, spaceErr } if space.GetSpaceType() != _spaceTypeProject { - return libregraph.Permission{}, errorcode.New(errorcode.InvalidRequest, "unsupported space type") + spaceTypeErr := errorcode.New(errorcode.InvalidRequest, "unsupported space type") + logger.Debug().Err(spaceTypeErr).Str(_logKeyDriveID, storagespace.FormatResourceID(driveID)).Str(_logKeyPermissionID, permissionID).Str(_logKeySpaceType, space.GetSpaceType()).Msg("unsupported space type") + return libregraph.Permission{}, spaceTypeErr } return s.GetPermission(ctx, space.GetRoot(), permissionID) diff --git a/services/graph/pkg/service/v0/api_driveitem_permissions_test.go b/services/graph/pkg/service/v0/api_driveitem_permissions_test.go index 91534afe48..0c31a9fc73 100644 --- a/services/graph/pkg/service/v0/api_driveitem_permissions_test.go +++ b/services/graph/pkg/service/v0/api_driveitem_permissions_test.go @@ -285,6 +285,10 @@ var _ = Describe("DriveItemPermissionsService", func() { _, err := s.UpdateSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid", libregraph.Permission{}) return err }, map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, HaveKeyWithValue("error", "no gateway available at 10.0.0.42"), 0), + Entry("GetSpaceRootPermission", "GetSpaceRootPermission", func(ctx context.Context, s svc.DriveItemPermissionsService) error { + _, err := s.GetSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid") + return err + }, map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, HaveKeyWithValue("error", "no gateway available at 10.0.0.42"), 0), ) It("does not mark the span of an expected client error as error, but records its error code", func() { @@ -419,6 +423,10 @@ var _ = Describe("DriveItemPermissionsService", func() { _, err := s.UpdateSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid", libregraph.Permission{}) return err }, map[string]string{"driveID": "1$2", "permissionID": "permissionid"}), + Entry("GetSpaceRootPermission", "personal", func(s svc.DriveItemPermissionsService) error { + _, err := s.GetSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid") + return err + }, map[string]string{"driveID": "1$2", "permissionID": "permissionid"}), ) var ( @@ -437,6 +445,10 @@ var _ = Describe("DriveItemPermissionsService", func() { _, err := s.UpdateSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid", libregraph.Permission{}) return err } + getSpaceRootPermission = func(s svc.DriveItemPermissionsService) error { + _, err := s.GetSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid") + return err + } missingSpaceResponse = &provider.ListStorageSpacesResponse{Status: status.NewOK(context.Background())} missingSpaceErr = errorcode.New(errorcode.ItemNotFound, "getting space").WithOrigin(errorcode.ErrorOriginCS3) // storage providers may report space names or paths in their status messages @@ -505,6 +517,12 @@ var _ = Describe("DriveItemPermissionsService", func() { map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, missingSpaceResponse, missingSpaceErr, "debug"), Entry("UpdateSpaceRootPermission: internal gateway error", updateSpaceRootPermission, map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, internalSpaceResponse, internalSpaceErr, "error"), + Entry("GetSpaceRootPermission: missing space", getSpaceRootPermission, + map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, missingSpaceResponse, missingSpaceErr, "debug"), + Entry("GetSpaceRootPermission: internal gateway error", getSpaceRootPermission, + map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, internalSpaceResponse, internalSpaceErr, "error"), + Entry("GetSpaceRootPermission: transport error", getSpaceRootPermission, + map[string]string{"driveID": "1$2", "permissionID": "permissionid"}, nil, transportSpaceErr, "error"), ) Describe("Invite", func() { @@ -2311,6 +2329,72 @@ var _ = Describe("DriveItemPermissionsService", func() { _, err := driveItemPermissionsService.GetPermission(ctx, driveItemId, "aaaaaaaaaaaaaaa") Expect(errorcode.IsErrorCode(err, errorcode.AccessDenied)).To(BeTrue()) }) + + It("logs a permission that is not listed for the item as debug and records the not found in its span", func() { + gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(statResponse, nil) + gatewayClient.On("ListShares", mock.Anything, mock.Anything).Return(&collaboration.ListSharesResponse{Status: status.NewOK(ctx)}, nil) + listPublicSharesResponse.Share = []*link.PublicShare{viewLink("aaaaaaaaaaaaaaa")} + gatewayClient.On("ListPublicShares", mock.Anything, mock.Anything).Return(listPublicSharesResponse, nil) + var logBuf bytes.Buffer + sr, tp := newSpanRecorder() + service, err := svc.NewDriveItemPermissionsService(log.Logger{Logger: zerolog.New(&logBuf)}, gatewaySelector, cache, cfg, tp) + Expect(err).ToNot(HaveOccurred()) + + _, err = service.GetPermission(context.WithValue(ctx, middleware.RequestIDKey, "request-42"), driveItemId, "ccccccccccccccc") + Expect(err).To(MatchError(errorcode.New(errorcode.ItemNotFound, "permission not found"))) + + entries := logEntries(&logBuf) + Expect(entries).To(ContainElement(SatisfyAll( + HaveKeyWithValue("level", "debug"), + HaveKeyWithValue("message", "permission not found"), + HaveKeyWithValue("request-id", "request-42"), + HaveKeyWithValue("itemID", "1$2!3"), + HaveKeyWithValue("permissionID", "ccccccccccccccc"), + ))) + Expect(entries).ToNot(ContainElement(HaveKeyWithValue("level", BeElementOf("error", "warn")))) + + // a not found is an expected client error: recorded by its code, the span is not marked as error + span := endedSpan(sr, "GetPermission") + Expect(span.Status().Code).To(Equal(codes.Unset)) + Expect(span.Attributes()).To(ContainElement(attribute.String("error.type", "itemNotFound"))) + // the listing succeeded, its span records no error + list := endedSpan(sr, "ListPermissions") + Expect(list.Parent().SpanID()).To(Equal(span.SpanContext().SpanID())) + Expect(list.Attributes()).ToNot(ContainElement(HaveField("Key", attribute.Key("error.type")))) + }) + + It("logs a failure of the listing once and marks both spans as error", func() { + gatewayErr := errors.New("no gateway available at 10.0.0.42") + gatewaySelector.EXPECT().Next().Unset() + gatewaySelector.EXPECT().Next().Return(nil, gatewayErr) + var logBuf bytes.Buffer + sr, tp := newSpanRecorder() + service, err := svc.NewDriveItemPermissionsService(log.Logger{Logger: zerolog.New(&logBuf)}, gatewaySelector, cache, cfg, tp) + Expect(err).ToNot(HaveOccurred()) + + _, err = service.GetPermission(context.WithValue(ctx, middleware.RequestIDKey, "request-42"), driveItemId, "permissionid") + Expect(err).To(MatchError(gatewayErr)) + + // ListPermissions logs the failure, GetPermission does not log it again + errorEntries := entriesAtLevel(logEntries(&logBuf), "error") + Expect(errorEntries).To(ConsistOf(SatisfyAll( + HaveKeyWithValue("request-id", "request-42"), + HaveKeyWithValue("itemID", "1$2!3"), + HaveKeyWithValue("errorCode", "generalException"), + HaveKeyWithValue("error", gatewayErr.Error()), + ))) + + Expect(sr.Ended()).To(HaveLen(2)) + span := endedSpan(sr, "GetPermission", "10.0.0.42") + list := endedSpan(sr, "ListPermissions", "10.0.0.42") + Expect(list.Parent().SpanID()).To(Equal(span.SpanContext().SpanID())) + Expect(list.SpanContext().TraceID()).To(Equal(span.SpanContext().TraceID())) + for _, s := range []sdktrace.ReadOnlySpan{span, list} { + Expect(s.Status().Code).To(Equal(codes.Error)) + Expect(s.Status().Description).To(Equal("generalException")) + Expect(s.Attributes()).To(ContainElement(attribute.String("error.type", "generalException"))) + } + }) }) Describe("GetSpaceRootPermission", func() { @@ -2331,6 +2415,35 @@ var _ = Describe("DriveItemPermissionsService", func() { Entry("personal", "personal"), Entry("virtual", "virtual"), ) + + It("records a GetSpaceRootPermission span as the parent of the GetPermission span", func() { + sr, tp := newSpanRecorder() + service, err := svc.NewDriveItemPermissionsService(log.NewLogger(), gatewaySelector, cache, cfg, tp) + Expect(err).ToNot(HaveOccurred()) + spaceRoot := &provider.ResourceId{StorageId: "1", SpaceId: "2", OpaqueId: "2"} + gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ + Status: status.NewOK(ctx), + StorageSpaces: []*provider.StorageSpace{ + {Id: &provider.StorageSpaceId{OpaqueId: "2"}, SpaceType: "project", Root: spaceRoot}, + }, + }, nil) + // the space root is gone, so the listing of its permissions fails with not found + gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(&provider.StatResponse{Status: status.NewNotFound(ctx, "not found")}, nil) + + _, err = service.GetSpaceRootPermission(ctx, &provider.ResourceId{StorageId: "1", SpaceId: "2"}, "permissionid") + Expect(errorcode.IsErrorCode(err, errorcode.ItemNotFound)).To(BeTrue()) + + root := endedSpan(sr, "GetSpaceRootPermission") + get := endedSpan(sr, "GetPermission") + list := endedSpan(sr, "ListPermissions") + Expect(get.Parent().SpanID()).To(Equal(root.SpanContext().SpanID())) + Expect(list.Parent().SpanID()).To(Equal(get.SpanContext().SpanID())) + for _, s := range []sdktrace.ReadOnlySpan{root, get, list} { + Expect(s.SpanContext().TraceID()).To(Equal(root.SpanContext().TraceID())) + Expect(s.Status().Code).To(Equal(codes.Unset)) + Expect(s.Attributes()).To(ContainElement(attribute.String("error.type", "itemNotFound"))) + } + }) }) Describe("DeletePermission", func() { From 8b4139136232a5feac39c24be9a7a03d46c67bfc Mon Sep 17 00:00:00 2001 From: OpenCloud Devops Date: Tue, 17 Nov 2026 15:58:52 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=89=20Release=209.2.0=20(#3967)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🎉 Release 9.1.1 * 🎉 Release 9.1.1 * 🎉 Release 9.1.1 * 🎉 Release 9.1.1 * 🎉 Release 9.1.1 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 * 🎉 Release 9.2.0 --- CHANGELOG.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fd6d01ea0..641d55f784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,55 @@ # Changelog +## [9.2.0](https://github.com/opencloud-eu/opencloud/releases/tag/v9.2.0) - 2026-11-17 + +### ❤️ Thanks to all contributors! ❤️ + +@AlexAndBear, @Pflum, @aduffeck, @asaah262, @butonic, @dragonchaser, @pbleser-oc, @v-scharf + +### 🔒 Security + +- Bump reva to v3.0.1 [[#4031](https://github.com/opencloud-eu/opencloud/pull/4031)] + +### 📚 Documentation + +- bump opencloud version to 9.2.0 [[#4033](https://github.com/opencloud-eu/opencloud/pull/4033)] + +### ✅ Tests + +- test(webdav): fix a data race in the thumbnail cache test [[#4011](https://github.com/opencloud-eu/opencloud/pull/4011)] +- test(graph): cover $select on the permissions list endpoints [[#4019](https://github.com/opencloud-eu/opencloud/pull/4019)] +- test(acceptance): fail on responses that are cut off after their headers [[#4009](https://github.com/opencloud-eu/opencloud/pull/4009)] +- test(search): cover trailing NOT operator in invalid KQL patterns [[#3982](https://github.com/opencloud-eu/opencloud/pull/3982)] +- test(guest-link): guest session does not override other credentials [[#3877](https://github.com/opencloud-eu/opencloud/pull/3877)] +- fix(ci): skip the font regeneration that restarts OnlyOffice [[#3996](https://github.com/opencloud-eu/opencloud/pull/3996)] +- test(search): wait for the first debouncer run instead of sleeping [[#3990](https://github.com/opencloud-eu/opencloud/pull/3990)] + +### 🐛 Bug Fixes + +- fix(graph): hide private user attributes from other users [[#4014](https://github.com/opencloud-eu/opencloud/pull/4014)] +- fix(markdown): create toc anchors like github-slugger [[#4005](https://github.com/opencloud-eu/opencloud/pull/4005)] +- fix(graph): return the drive id in remoteItem.parentReference.driveId [[#4006](https://github.com/opencloud-eu/opencloud/pull/4006)] +- fix(graph): name the space image size limit after space images [[#3993](https://github.com/opencloud-eu/opencloud/pull/3993)] +- fix(graph): succeed when unassigning tags a resource doesn't have [[#3950](https://github.com/opencloud-eu/opencloud/pull/3950)] +- fix(graph): port share permission and link fixes [[#3944](https://github.com/opencloud-eu/opencloud/pull/3944)] +- fix(graph): refuse space images too large for a thumbnail [[#3986](https://github.com/opencloud-eu/opencloud/pull/3986)] +- Fix Reva config to also validate OC_CACHE_* tls settings and fix the disable_persistence key [[#3913](https://github.com/opencloud-eu/opencloud/pull/3913)] +- fix(graph): return the identities of the identity backend on /me [[#3981](https://github.com/opencloud-eu/opencloud/pull/3981)] +- fix(graph): reject empty and invisible drive names on update [[#3946](https://github.com/opencloud-eu/opencloud/pull/3946)] + +### 📈 Enhancement + +- graph: rate limit the personal data export [[#3973](https://github.com/opencloud-eu/opencloud/pull/3973)] +- feat(graph): add the v1beta1 endpoints for a single drive [[#3941](https://github.com/opencloud-eu/opencloud/pull/3941)] +- feat: merge the workpagages branch into main [[#3956](https://github.com/opencloud-eu/opencloud/pull/3956)] +- feat(graph): allow client-supplied drive IDs when creating spaces [[#3899](https://github.com/opencloud-eu/opencloud/pull/3899)] +- feat(graph): improve logging and tracing for drive item permissions [[#3881](https://github.com/opencloud-eu/opencloud/pull/3881)] +- feat(graph): add GET endpoints for single sharing permissions [[#3928](https://github.com/opencloud-eu/opencloud/pull/3928)] + +### 📦️ Dependencies + +- [full-ci] chore: bump web to v8.3.0 [[#4027](https://github.com/opencloud-eu/opencloud/pull/4027)] + ## [9.1.0](https://github.com/opencloud-eu/opencloud/releases/tag/v9.1.0) - 2026-11-11 ### ❤️ Thanks to all contributors! ❤️