Skip to content

Commit

Permalink
Updated the s3 error msg in InvalidArgument error
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Chouhan <[email protected]>
  • Loading branch information
achouhan09 committed Jan 8, 2025
1 parent eaf259a commit ffa8634
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/endpoint/s3/ops/s3_put_bucket_lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function put_bucket_lifecycle(req) {
if (rule.ID?.length === 1) {
if (rule.ID[0].length > config.MAX_RULE_ID_LENGTH) {
dbg.error('Rule should not have ID length exceed allowed limit of ', config.MAX_RULE_ID_LENGTH, ' characters', rule);
throw new S3Error(S3Error.InvalidArgument);
throw new S3Error({ ...S3Error.InvalidArgument, message: 'ID length should not exceed allowed limit of 255' });
} else {
current_rule.id = rule.ID[0];
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/lifecycle/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ exports.test_rule_id_length = async function(Bucket, Key, s3) {

try {
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
// if no error occurs, explicitly fail the test
assert.fail('Expected error for ID length exceeding maximum allowed characters, but request was successful');
} catch (error) {
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument: id length exceeding 255 characters');
console.log('Expected error received, id length exceeding', config.MAX_RULE_ID_LENGTH, 'characters');
Expand Down

0 comments on commit ffa8634

Please sign in to comment.