Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added restriction to limit the ID length to 255 characters in bucket lifecycle rules #8628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

achouhan09
Copy link
Member

@achouhan09 achouhan09 commented Dec 26, 2024

Explain the changes

  1. Currently, any length of ID can be accepted, as a fix we have added restriction to limit the length of ID to 255 characters only in bucket lifecycle rules.

Issues: Fixed #xxx / Gap #xxx

  1. Fixed: NSFS | S3 | Lifecycle: Bucket lifecycle configuration accepts long rule ID #8549

Testing Instructions:

  • Tests added

@achouhan09 achouhan09 requested review from a team and aspandey and removed request for a team December 26, 2024 16:43
@achouhan09 achouhan09 changed the title NSFS| Added restriction to limit the ID length to 255 characters in bucket lifecycle rules Added restriction to limit the ID length to 255 characters in bucket lifecycle rules Dec 30, 2024
@achouhan09 achouhan09 requested a review from romayalon December 30, 2024 12:05
@romayalon
Copy link
Contributor

Hey @achouhan09

  1. Can you please link to the Issues section the bug you are fixing?
  2. Please add tests
  3. Throwing InvalidArgument error code is based on the AWS S3 protocol?

@achouhan09
Copy link
Member Author

Hi @romayalon
I think the InvalidArgument error code is suitable for this case as there is issue found in parameters passed. check this

Added issue link and tests. Thanks

@@ -88,7 +88,12 @@ async function put_bucket_lifecycle(req) {
};

if (rule.ID?.length === 1) {
current_rule.id = rule.ID[0];
if (rule.ID[0].length > 255) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting to move the 255 to a const variable for easier reading of the code and maintenance - in case in the future it will be changed we need to change it in one place only, for example:
const MAX_LENGTH_RULE_ID = 255 and reuse it in the error message.

const putLifecycleParams = id_length_lifecycle_configuration(Bucket, Key);

await s3.putBucketLifecycleConfiguration(putLifecycleParams)
.catch(error => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use a promise chain here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NSFS | S3 | Lifecycle: Bucket lifecycle configuration accepts long rule ID
3 participants