Repository navigation
fix: validate bucket names against the server's naming rules - #326
Closed
AndrewGanzha wants to merge 1 commit into
Closed
AndrewGanzha wants to merge 1 commit into
AndrewGanzha wants to merge 1 commit into
Conversation
The Create Bucket dialog only rejected names shorter than 3 characters or containing uppercase letters. A name pasted with spaces or zero-width characters therefore passed client validation, failed on the server, and reported nothing in the name field (rustfs/rustfs#9805). getBucketNameError now mirrors the server's strict bucket name validation (rustfs/rustfs, crates/ecstore/src/bucket/utils.rs, check_bucket_name_common): allowed character set, names starting and ending with a letter or number, no periods next to each other or to a hyphen, no IP-address-shaped names, and no reserved name. Whitespace and invisible characters get their own message because they survive trim() and look correct in the field. All new messages are translated for every locale, and the dialog test reproduces the pasted zero-width name from the report.
Member
|
same #325 |
overtrue
requested changes
Nov 30, 2026
overtrue
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for the thorough bucket-name validation parity work. Requesting changes because this PR currently has merge conflicts and missing CI results:
- Merge conflict after
rustfs/console#325landed:rustfs/console#325has been merged intomainto addressrustfs/rustfs#9805(addingINVALID_BUCKET_NAME_CHARACTERinlib/bucket-name.ts, locale strings acrossi18n/locales/*.json, andhasValidBucketName/aria-describedby/ capability-check updates incomponents/buckets/new-form.tsx). As a result, this branch now conflicts acrosslib/bucket-name.ts, all 15i18n/locales/*.jsonfiles,tests/lib/bucket-name.test.ts, andtests/lib/form-interaction.test.ts. - Missing CI checks: No CI check runs are currently reported on
fix/bucket-name-validation.
If you plan to follow up with the additional S3/server-parity rules (INVISIBLE_BUCKET_NAME_PATTERN, BUCKET_NAME_EDGE_PATTERN, INVALID_BUCKET_NAME_SEQUENCE_PATTERN, IP_ADDRESS_PATTERN, RESERVED_BUCKET_NAMES) on top of main:
- Please rebase onto
mainand resolve the conflicts while keeping the form and accessibility updates from#325incomponents/buckets/new-form.tsx. - Minor note on
lib/bucket-name.ts:IP_ADDRESS_PATTERN = /^(\d+\.){3}\d+$/matches any 4 dot-separated digit groups including out-of-range octets (e.g.999.999.999.999); please verify whether that matches the server check or should restrict octets to0–255. - Once rebased, please ensure all CI checks run and pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Create Bucket dialog accepted names the server rejects.
getBucketNameErroronly checked the length (3–63 aftertrim()) and uppercase letters, so a name pasted with spaces or zero-width characters passed client validation, theCreateBucketrequest failed server-side, and the name field showed no validation error at all — the user saw only a generic failure toast (rustfs/rustfs#9805).This PR makes the dialog's validation mirror the server's own strict bucket name validation (
rustfs/rustfs,crates/ecstore/src/bucket/utils.rs,check_bucket_name_common):Bucket names cannot contain spaces or invisible charactersa-z0-9.-Bucket names can only contain lowercase letters, numbers, periods, and hyphensBucket names must start and end with a lowercase letter or number..,.-,-.Bucket names must not contain consecutive periods or a period next to a hyphenBucket names must not look like an IP addressrustfsBucket name is reservedWhitespace and invisible characters get their own message on purpose: they survive
trim()and look correct in the field, which is exactly what made #9805 confusing. Message keys are added to all 15 locale files, in alphabetical position, fully translated.Files:
lib/bucket-name.ts,tests/lib/bucket-name.test.ts,tests/lib/form-interaction.test.ts,i18n/locales/*.json(15).Type of Change
Testing
tests/lib/bucket-name.test.tscovers every new rule, the exact pasted name from the report (s\u200bu\u200bport-service-files), bidi/format characters, and names that must stay valid (bucket.demo,1-bucket.2026).tests/lib/form-interaction.test.tsmountsBucketNewFormwith the real validator, pastes the reported name, and asserts the inline error text renders, the Create button is disabled, and nocreateBucketrequest is made.Checklist
Related Issues
Fixes rustfs/rustfs#9805 — the report is filed against the Console bucket dialog but lives in the server repository.
Screenshots (if applicable)
I could not capture before/after screenshots: the Console cannot be logged into without a running RustFS backend, so the dialog is unreachable locally. The behaviour is instead pinned by the dialog test above (error text in the field, Create disabled, no request sent). Happy to add screenshots if you prefer to review the visual state — the dialog reuses the existing
FieldErrorstyling, no markup changed.Additional Notes
use-bucket.tsalready sends, so the console never accepts a name it would then send differently.pnpm-lock.yamlonmaincurrently contains two YAML documents (a stray pnpm self-management lockfile block at lines 1–101, then---, then the real lockfile).pnpm install --frozen-lockfilefails on a clean clone because of it. I left the file untouched here as it is out of scope.