Skip to content

Reject PUT /object if combined bucket and file path exceeds S3 maximum#308

Merged
TimCsaky merged 1 commit intomasterfrom
chore/enforce-object-key-length
Jun 10, 2025
Merged

Reject PUT /object if combined bucket and file path exceeds S3 maximum#308
TimCsaky merged 1 commit intomasterfrom
chore/enforce-object-key-length

Conversation

@norrisng-bc
Copy link
Contributor

Description

Reject all PUT /object requests with a combined bucket and file path exceeding 1024 bytes (i.e. bucket path + file path + filename, including all /'s in between).

This is because S3 has a hard limit of 1024 bytes on object keys.

Previously, such requests were already being rejected, but with a HTTP 502 ("detail": "Bucket communication error") instead.

SHOWCASE-3792

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

The focus of the Jira ticket was on potentially problematic characters in bucket (i.e. BCBox folder) names.

However, the only way I was able to break COMS was by creating objects with excessively long filenames that exceed the S3 max key length. This wasn't part of the original ticket, but nonetheless improves handling of potentially problematic bucket/file names.

S3 supports object keys (i.e. bucket and file paths combined, including slashes) up to 1024 bytes
@github-actions
Copy link

github-actions bot commented Jun 6, 2025

Coverage Report

Totals Coverage
Statements: 57.02% ( 3066 / 5377 )
Methods: 47.11% ( 334 / 709 )
Lines: 63.83% ( 1842 / 2886 )
Branches: 49.94% ( 890 / 1782 )

@TimCsaky TimCsaky merged commit 1983271 into master Jun 10, 2025
14 of 17 checks passed
@norrisng-bc norrisng-bc deleted the chore/enforce-object-key-length branch July 23, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants