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

NC | CLI | Added a validation to check if whitespace is not trimmed from string value for a flag #8722

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

achouhan09
Copy link
Member

@achouhan09 achouhan09 commented Jan 24, 2025

Explain the changes

  1. Problem: Leading spaces before a flag value, when using =, caused the value to be split into an empty string ('') and the actual value, resulting in faulty flag assignments.
  2. Solution: A validation has been added to check if the flag value become empty due to incorrect formatting. It checks if argv._ has more than two elements and throws an error if invalid values are detected.

This prevents incorrect assignments and ensures flag values are valid.

Issues: Fixed #xxx / Gap #xxx

  1. Fixed: NC | CLI | Weird behavior of the CLI when adding space before access_key/secret_key flag #8319

Testing Instructions:

  1. Try creating account with noobaa-cli using below command:
    $ sudo node src/cmd/manage_nsfs account add --name aayush2 --uid=9 --gid=9 --new_buckets_path= tmp/
  • Tests added

@achouhan09 achouhan09 requested review from liranmauda, a team and jackyalbo and removed request for a team January 24, 2025 11:01
@achouhan09 achouhan09 force-pushed the account-space-fix branch 2 times, most recently from 3ced00b to 0b8a0a1 Compare January 29, 2025 09:49
Copy link
Contributor

@shirady shirady left a comment

Choose a reason for hiding this comment

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

LGTM

…' which may be due to leading space in flag values

Signed-off-by: Aayush Chouhan <[email protected]>

Updated the code after Romy's PR is merged

Signed-off-by: Aayush Chouhan <[email protected]>

Updated the logic and tests

Signed-off-by: Aayush Chouhan <[email protected]>

Updated to enum, added examples and error msg

Signed-off-by: Aayush Chouhan <[email protected]>

Update the function name and unit tests

Signed-off-by: Aayush Chouhan <[email protected]>
@achouhan09 achouhan09 merged commit e1e56a8 into noobaa:master Feb 17, 2025
11 checks passed
@achouhan09 achouhan09 deleted the account-space-fix branch February 17, 2025 08:44
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.

NC | CLI | Weird behavior of the CLI when adding space before access_key/secret_key flag
4 participants