Skip to content

Commit

Permalink
Updated the s3 error msg for invalid argument error and updated the test
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 103e2d1 commit 55ba75f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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 @@ -98,7 +98,7 @@ async function put_bucket_lifecycle(req) {
// Check for duplicate ID in the rules
if (id_set.has(current_rule.id)) {
dbg.error('Rule ID must be unique. Found same ID for more than one rule: ', current_rule.id);
throw new S3Error(S3Error.InvalidArgument);
throw new S3Error({ ...S3Error.InvalidArgument, message: 'Rule ID must be unique. Found same ID for more than one rule'});
}
id_set.add(current_rule.id);

Expand Down
3 changes: 2 additions & 1 deletion src/test/lifecycle/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,9 @@ exports.test_rule_duplicate_id = async function(Bucket, Key, s3) {

try {
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
// if no error occurs, explicitly fail the test
assert.fail('Expected error for duplicate rule ID, but request was successful');
} catch (error) {
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument: duplicate ID found in the rules');
console.log('Expected error received: each rule must have a unique ID, duplicate ID found');
}
};

0 comments on commit 55ba75f

Please sign in to comment.