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 5 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

src/endpoint/s3/ops/s3_put_bucket_lifecycle.js Outdated Show resolved Hide resolved
src/test/lifecycle/common.js Outdated Show resolved Hide resolved
@@ -7,6 +7,7 @@ const dbg = require('../../../util/debug_module')(__filename);
const S3Error = require('../s3_errors').S3Error;

const true_regex = /true/i;
const max_length_rule_id = 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 prefer using capital letters (so it is easier to know when reading the statement that it is a const without jumping to the declaration).

Suggested change
const max_length_rule_id = 255;
const MAX_LENGTH_RULE_ID = 255;

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, Thanks

@@ -3,6 +3,7 @@

const assert = require('assert');

const max_length_rule_id = 255;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you declare the max in a place where we can import it and reuse it?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can use config.js here. Updated, Thanks

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 not sure config.js is the right place, as it should not be configured.
I can suggest existing s3_utils (or if you want I think we can create s3_constants under src/endpoint/s3/).

src/test/lifecycle/common.js Outdated Show resolved Hide resolved
@shirady
Copy link
Contributor

shirady commented Jan 6, 2025

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

Could you test it in AWS and attach the results here?

@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

Could you test it in AWS and attach the results here?

Screenshot from 2025-01-07 16-16-49

@shirady
Copy link
Contributor

shirady commented Jan 7, 2025

replied to comment
@achouhan09 does noobaa use the same error message?
I mean this: "ID length should not exceed allowed limit of 255"

@achouhan09
Copy link
Member Author

achouhan09 commented Jan 7, 2025

replied to comment @achouhan09 does noobaa use the same error message? I mean this: "ID length should not exceed allowed limit of 255"

For NooBaa, we will only get InvalidArgument error and no error msg on the command line. But we can check the error logs in the endpoint pod which is similar to what you are referring. Below is the NooBaa error:

An error occurred (InvalidArgument) when calling the PutBucketLifecycleConfiguration operation: Invalid Argument

@achouhan09
Copy link
Member Author

replied to comment @achouhan09 does noobaa use the same error message? I mean this: "ID length should not exceed allowed limit of 255"

@shirady updated the error msg. Thanks

current_rule.id = rule.ID[0];
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, message: 'ID length should not exceed allowed limit of 255' });
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new S3Error({ ...S3Error.InvalidArgument, message: 'ID length should not exceed allowed limit of 255' });
throw new S3Error({ ...S3Error.InvalidArgument, message: `ID length should not exceed allowed limit of ${config.MAX_RULE_ID_LENGTH}` });

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