Changelog - 2026-11-08
A storage key segment is limited to 255 bytes, and a key cannot end with a slash
Bug FixIn one line. A long non-ASCII name and a key ending with / are now refused as an invalid name (400), instead of failing later or overwriting another object.
What changed
- A segment is measured in bytes.
isValidSegment(and soisValidObjectKeyandisValidBucketName) allows at most 255 bytes in UTF-8 per segment, not 255 characters. A file system limits a name in bytes, so a name of 128é(128 characters, 256 bytes) used to pass the check. Inside a folder,DiskHelperthen failed a write with a rawENAMETOOLONG(a 500) and answered a read with a 404. - A whole key is measured in bytes too. The 1024 limit of a key counts UTF-8 bytes, so a deep path of multi-byte names that fit in 1024 characters is refused as an invalid name instead of failing in the storage backend.
- A key cannot end with
/.isValidObjectKeyrefusesphotos/a.png/and a directory marker such asphotos/. On disk,photos/a.png/was written asphotos/a.png, so two different keys named the same file.
Who is affected
- Keys that end with
/. EveryDiskHelperobject call, every static-asset object route (400 core.static_asset.object_name_invalid), anduploadandwriteStreamonBunS3Helpernow refuse them with a 400. Drop the trailing slash. - Names longer than 255 bytes. Refused with the same
400. A name in a script that uses two or more bytes per character (Vietnamese with marks, Cyrillic, CJK, emoji) reaches the limit before 255 characters. - Listing. A listing
prefixending with/andcontroller.keyPrefixare not object keys and keep working. - Everyone else. No action needed.
Details
- The limit of a whole key (1024) is counted in UTF-8 bytes too. The length of an upload's
originalNamewhen it is metadata only (255) still counts characters: it is never a file name or a key.
| File | Package |
|---|---|
src/modules/storage/base.ts | helpers |