Automattic / vip-cli

The VIP-CLI
https://docs.wpvip.com/vip-cli/
MIT License
58 stars 17 forks source link

Fix --limit arg handling in vip logs command #2093

Closed ariskataoka closed 1 week ago

ariskataoka commented 1 week ago

Description

This PR fixes an issue where invalid inputs like --limit=abc were being replaced with the default before validation.

  1. Ensure the default value for --limit (500) is applied only when the flag isn’t provided.
  2. Preserve and validate raw user input for --limit, preventing unintended overrides.
  3. Added a LIMIT_DEFAULT constant for clarity and consistency.

Pull request checklist

New release checklist

Steps to Test

Outline the steps to test and verify the PR here.

  1. Check out PR.
  2. Run npm run build
  3. Test no --limit provided: 3.1. Runnode ./dist/bin/vip-logs @[APP].[ENV] 3.2. Verify: it should use the default limit - 500
  4. Test explicit string limit: 4.1. Run node ./dist/bin/vip-logs @[APP].[ENV] --limit=cookies 4.2 Verify: it should throw an error: Invalid limit: cookies. It should be a number between 1 and 5000.
  5. Test explicit number limit: 5.1. Runnode ./dist/bin/vip-logs @[APP].[ENV] --limit=5001 5.2. Verify: it should throw an error: Invalid limit: 5001. It should be a number between 1 and 5000.
github-actions[bot] commented 1 week ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

sonarcloud[bot] commented 1 week ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud