fix: add bucket name length constraint #685
Merged
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.
What kind of change does this PR introduce?
Bug fix, restricting bucket name length to a max of 63 characters to adhere to S3 Bucket naming rules
What is the current behavior?
No restrictions on the length of bucket name
What is the new behavior?
Added Postgres buckets name length check constraint and updated
isValidBucketName
function. Also added test inbucket.test.ts
to verify400
is being returned when issuing aPOST
request with name longer than 63 characters.Additional context
I updated the
fromDBerror
switch statement to include the new pgError.code for the buckets name length check constraint. TheERRORS.InvalidBucketName
error requires the bucket name I opted to parse it from thepgError.detail
ExamplepgError.detail
:'Failing row contains (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, null, 2025-05-03 21:04:15.907656+00, 2025-05-03 21:04:15.907656+00, f, f, null, null, null).'