Skip to content

fix(graph): refuse space images too large for a thumbnail - #3986

Open
pbleser-oc wants to merge 1 commit into
opencloud-eu:workpagagesfrom
pbleser-oc:fix/graph-space-image-size
Open

pbleser-oc wants to merge 1 commit into
opencloud-eu:workpagagesfrom
pbleser-oc:fix/graph-space-image-size

Conversation

@pbleser-oc

@pbleser-oc pbleser-oc commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Setting a file as the image of a space that is too large for the thumbnail generator succeeded, but the space then showed no image, since a space image is only ever shown as a thumbnail, and nobody got an error. Graph now refuses such a file with 413 Request Entity Too Large.

Changes

  • PATCH /graph/v1.0/drives/{id} with an image in special looks up the size of the file first, and refuses a file above the limit with 413, without changing the space. If the file can't be looked up, the request fails with that error (e.g. 404), also without changing the space.
  • The limit is the one of the thumbnail generator. Graph reads it under the same names as the webdav and thumbnails services, in the same order: OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE, then the older THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE, which still wins as it does in the other two. So one setting keeps the three in agreement. GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE (yaml thumbnails.max_input_image_file_size) sets a lower limit for space images alone. Default 50MB, empty for unlimited, as for the other two services.
  • The default 50MB is one constant now, ThumbnailsMaxInputImageFileSize in pkg/config/defaults, used by graph, webdav and thumbnails.
  • A value that isn't a size stops graph from starting, with an error that names the setting.
  • New exported ErrSpaceImageTooLarge.
  • Not checked: the space readme, an entry without an id or with an empty id (unchanged), and the width and height limits of the generator, which would need the whole image to be read.
  • Docs: a "Space Images" section in the graph README (with curl examples), and the thumbnails README and the webdav MIGRATION.md say that graph reads the setting too.

Clients

A client that overwrites the file of the current space image with the new content, as the web UI does, has replaced that content already when graph refuses the new one, so the space shows no image in that case. The web UI also shows only a generic error for a 413. The follow-up for the web UI is opencloud-eu/web#4461.

Tests

  • Unit tests (drives_space_image_test.go): too large → 413 and nothing stored, exactly the limit, empty limit, the readme, an empty image id, lookup failures (404, 500), an invalid limit at startup.
  • Parser test: graph and the thumbnails service read the same value from the shared, the old and both names, and the graph name sets a lower limit.
  • Acceptance: a new @env-config scenario in apiSpaces/changeSpaces.feature (413 for a file above the limit); the feature passes locally on posix.

AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and the docs.

A space image is only ever shown as a thumbnail. When a file larger
than the thumbnail generator accepts was set as the image of a space,
the PATCH of the drive succeeded, but no thumbnail could be made of the
file, so the space showed no image and nobody got an error.

Before setting the image, graph now looks up the size of the file, and
refuses a file above the limit with 413 Request Entity Too Large,
without changing the space. The limit is the one of the thumbnail
generator: graph reads it under the same names as the webdav and
thumbnails services (OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE and the
older THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE, 50MB by default, empty for
unlimited), so one setting keeps the three in agreement.
GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE sets a lower limit for space
images alone.

The default of 50MB is now one constant, which the graph, webdav and
thumbnails services all use.

Only the file size is checked: the dimension limits of the generator
would need the whole image to be read. The space readme has no limit,
and an empty image id is passed on unchecked, as before.

Assisted-by: Claude Code:claude-opus-5-5
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 32 complexity

Metric Results
Complexity 32

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant