fix(graph): name the space image size limit after space images

The variable that sets a lower size limit for space images alone was
named after the service, GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE,
which reads like a limit for thumbnails in general. Rename it to
OC_SPACE_IMAGE_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE, and the yaml key
from thumbnails.max_input_image_file_size to
thumbnails.space_image_max_input_image_file_size.

The shared names OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE and
THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE are unchanged. Neither renamed
setting has been released yet.

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Pascal Bleser committed 2026-11-13 19:01:53 +01:00
1 parent 55b5e7db73
commit ad140be6eb
7 files changed
+15 -15

No files matched your search

+4 -4
View File
@@ -108,14 +108,14 @@ Setting the limit there sets it for all three services:
OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE=100MB
```
`GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` sets a limit for space images alone. It only makes sense
to set it lower than the limit of the thumbnail generator: a space image between the two would be
accepted, but not shown.
`OC_SPACE_IMAGE_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` sets a limit for space images alone. It only
makes sense to set it lower than the limit of the thumbnail generator: a space image between the two
would be accepted, but not shown.
```bash
# thumbnails up to 100 MB, but space images only up to 10 MB
OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE=100MB
GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE=10MB
OC_SPACE_IMAGE_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE=10MB
```
Only the file size is checked. The thumbnail generator also has limits for the width and the height
+1 -1
View File
@@ -217,5 +217,5 @@ type Thumbnails struct {
AdditionalSourceTypes []string `yaml:"additional_source_types" env:"OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES;GRAPH_THUMBNAILS_ADDITIONAL_SOURCE_TYPES" desc:"Additional mime types a preview is announced for, the same list the webdav service attempts previews for. The types the build ships are included; this only adds to them." introductionVersion:"9.0.0"`
// read under the same names as by webdav and the thumbnails service, so that
// graph doesn't accept a space image no thumbnail can be made of
MaxInputImageFileSize string `yaml:"max_input_image_file_size" env:"OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE" desc:"The maximum file size of an image that can be set as the image of a space. A larger one is refused with HTTP 413, because no thumbnail can be made of it, and space images are only shown as thumbnails. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB], example: 50MB. An empty value means unlimited." introductionVersion:"%%NEXT%%"`
SpaceImageMaxInputImageFileSize string `yaml:"space_image_max_input_image_file_size" env:"OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;OC_SPACE_IMAGE_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE" desc:"The maximum file size of an image that can be set as the image of a space. A larger one is refused with HTTP 413, because no thumbnail can be made of it, and space images are only shown as thumbnails. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB], example: 50MB. An empty value means unlimited." introductionVersion:"%%NEXT%%"`
}
@@ -90,7 +90,7 @@ func DefaultConfig() *config.Config {
UsersCacheTTL: 60,
},
Thumbnails: config.Thumbnails{
MaxInputImageFileSize: ocdefaults.ThumbnailsMaxInputImageFileSize,
SpaceImageMaxInputImageFileSize: ocdefaults.ThumbnailsMaxInputImageFileSize,
},
Identity: config.Identity{
Backend: "ldap",
@@ -43,7 +43,7 @@ var _ = Describe("the maximum size of a space image", func() {
generator := thumbnailsdefaults.DefaultConfig()
Expect(thumbnailsparser.ParseConfig(generator)).To(Succeed())
Expect(cfg.Thumbnails.MaxInputImageFileSize).To(Equal(want))
Expect(cfg.Thumbnails.SpaceImageMaxInputImageFileSize).To(Equal(want))
Expect(generator.Thumbnail.MaxInputImageFileSize).To(Equal(want))
},
Entry("from the shared name", map[string]string{
@@ -60,9 +60,9 @@ var _ = Describe("the maximum size of a space image", func() {
It("can be set lower for graph alone", func() {
GinkgoT().Setenv("OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE", "100MB")
GinkgoT().Setenv("GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE", "10MB")
GinkgoT().Setenv("OC_SPACE_IMAGE_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE", "10MB")
Expect(decodeEnv().Thumbnails.MaxInputImageFileSize).To(Equal("10MB"))
Expect(decodeEnv().Thumbnails.SpaceImageMaxInputImageFileSize).To(Equal("10MB"))
})
})
@@ -63,7 +63,7 @@ var _ = Describe("setting the image of a space", func() {
// sets the maximum size of a space image, as the configuration does
setMaxSize := func(size string) {
cfg.Thumbnails.MaxInputImageFileSize = size
cfg.Thumbnails.SpaceImageMaxInputImageFileSize = size
var err error
svc, err = newService()
Expect(err).ToNot(HaveOccurred())
@@ -207,8 +207,8 @@ var _ = Describe("setting the image of a space", func() {
)
It("doesn't start with a maximum size that isn't a size", func() {
cfg.Thumbnails.MaxInputImageFileSize = "fifty megabytes"
cfg.Thumbnails.SpaceImageMaxInputImageFileSize = "fifty megabytes"
_, err := newService()
Expect(err).To(MatchError(ContainSubstring("thumbnails.max_input_image_file_size")))
Expect(err).To(MatchError(ContainSubstring("thumbnails.space_image_max_input_image_file_size")))
})
})
+2 -2
View File
@@ -201,10 +201,10 @@ func NewService(opts ...Option) (Graph, error) { //nolint:maintidx
natskv: options.NatsKeyValue,
}
if raw := strings.TrimSpace(options.Config.Thumbnails.MaxInputImageFileSize); raw != "" {
if raw := strings.TrimSpace(options.Config.Thumbnails.SpaceImageMaxInputImageFileSize); raw != "" {
size, err := bytesize.Parse(raw)
if err != nil {
return svc, fmt.Errorf("invalid thumbnails.max_input_image_file_size %q: %w", raw, err)
return svc, fmt.Errorf("invalid thumbnails.space_image_max_input_image_file_size %q: %w", raw, err)
}
svc.maxSpaceImageSize = size.Bytes()
}
@@ -374,7 +374,7 @@ Feature: Change data of space
@env-config
Scenario: user cannot set an image file larger than the maximum size as space image of the space via the Graph API
Given the config "GRAPH_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE" has been set to "10"
Given the config "OC_SPACE_IMAGE_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE" has been set to "10"
And user "Alice" has created a folder ".space" in space "Project Jupiter"
And user "Alice" has uploaded a file inside space "Project Jupiter" with content "nineteen bytes long" to ".space/spaceImage.jpg"
When user "Alice" sets the file ".space/spaceImage.jpg" as a space image in a special section of the "Project Jupiter" space