From dd93fd4d438120b4033beaa56f5c85e2e388e0b6 Mon Sep 17 00:00:00 2001 From: Pascal Bleser Date: Fri, 13 Nov 2026 19:15:45 +0100 Subject: [PATCH] docs(graph): mention the v1beta1 route for space images A space image can be assigned with a PATCH of the drive on the v1beta1 route as well, and the size limit applies there the same way. Say so in the README, and cover the refusal of a too large image on that route in the tests. Assisted-by: Claude Code:claude-opus-5-5 --- services/graph/README.md | 5 ++-- .../pkg/service/v0/drives_space_image_test.go | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/services/graph/README.md b/services/graph/README.md index ea1876404b..9ace6c37c8 100644 --- a/services/graph/README.md +++ b/services/graph/README.md @@ -58,8 +58,9 @@ on the filters supported when querying users. ## Space Images The image of a space is a file in the space, usually in its `.space` folder. A space manager -uploads the file, and then assigns it with `PATCH /graph/v1.0/drives/{drive-id}`, naming the id of -the file in the `image` entry of `special`: +uploads the file, and then assigns it with `PATCH /graph/v1.0/drives/{drive-id}` (or +`PATCH /graph/v1beta1/drives/{drive-id}`, which works the same way), naming the id of the file in +the `image` entry of `special`: ```bash # upload the image into the .space folder of the space; the response header diff --git a/services/graph/pkg/service/v0/drives_space_image_test.go b/services/graph/pkg/service/v0/drives_space_image_test.go index efa66a181c..4a7899b17f 100644 --- a/services/graph/pkg/service/v0/drives_space_image_test.go +++ b/services/graph/pkg/service/v0/drives_space_image_test.go @@ -69,8 +69,9 @@ var _ = Describe("setting the image of a space", func() { Expect(err).ToNot(HaveOccurred()) } - // sends a PATCH of the space with the given file as its special folder - patchSpecial := func(folder, fileID string) { + // sends a PATCH of the space with the given file as its special folder to + // the given handler + patchSpecialVia := func(update http.HandlerFunc, path, folder, fileID string) { drive := libregraph.NewDriveUpdate() drive.SetSpecial([]libregraph.DriveItem{{ Id: libregraph.PtrString(fileID), @@ -79,11 +80,16 @@ var _ = Describe("setting the image of a space", func() { body, err := json.Marshal(drive) Expect(err).ToNot(HaveOccurred()) - r := httptest.NewRequest(http.MethodPatch, "/graph/v1.0/drives/{driveID}/", bytes.NewBuffer(body)) + r := httptest.NewRequest(http.MethodPatch, path, bytes.NewBuffer(body)) rctx := chi.NewRouteContext() rctx.URLParams.Add("driveID", "storageid$spaceid") r = r.WithContext(context.WithValue(ctx, chi.RouteCtxKey, rctx)) - svc.UpdateDrive(rr, r) + update(rr, r) + } + + // sends a PATCH of the space with the given file as its special folder + patchSpecial := func(folder, fileID string) { + patchSpecialVia(svc.UpdateDrive, "/graph/v1.0/drives/{driveID}/", folder, fileID) } // the stat of the image file answers with the given size @@ -149,6 +155,16 @@ var _ = Describe("setting the image of a space", func() { expectNothingStored() }) + It("refuses an image above the maximum size on the v1beta1 route too", func() { + updateSucceeds() + statReturnsSize(1001) + + patchSpecialVia(svc.UpdateDriveV1Beta1, "/graph/v1beta1/drives/{driveID}/", "image", imageID) + + Expect(rr.Code).To(Equal(http.StatusRequestEntityTooLarge)) + expectNothingStored() + }) + It("accepts an image of exactly the maximum size", func() { updateSucceeds() statReturnsSize(1000) // KB is 1000 bytes, KiB would be 1024