[cli] fix: reject non-canonical numeric inputs - #282
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR tightens CLI numeric input validation in KeepGPU to require plain ASCII digit tokens, rejecting non-canonical spellings like underscore-separated numbers ( ChangesASCII-only numeric CLI validation
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as cli.main
participant Legacy as _apply_legacy_threshold
participant Validators as Validators (interval/busy-threshold/vram)
User->>CLI: keep-gpu --threshold value
CLI->>Legacy: _apply_legacy_threshold(value)
Legacy->>Legacy: classify token via regex
Legacy-->>CLI: legacy_vram / legacy_busy_threshold
CLI->>Validators: validate derived values
Validators-->>CLI: BadParameter or validated value
CLI-->>User: proceed to _run_blocking or error
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/keep_gpu/cli.py`:
- Around line 58-61: The CLI numeric token rules are inconsistent because
_CLI_INTEGER_TOKEN_RE and _CLI_NUMBER_TOKEN_RE allow a leading + for flags like
--interval, --busy-threshold, and legacy --threshold, but the --gpu-ids parsing
path rejects it. Update the gpu-id parsing logic in keep_gpu CLI helpers to use
the same canonical token rules as the other numeric flags, or explicitly
document and add tests for the intentional exception so the behavior is
consistent and discoverable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5be7110e-3024-4335-be56-e17b4ddfa028
📒 Files selected for processing (6)
AGENTS.mddocs/guides/cli.mddocs/reference/cli.mdsrc/keep_gpu/cli.pytests/test_cli_service_commands.pytests/test_cli_thresholds.py
Summary
--gpu-ids,--interval,--busy-threshold, and legacy--thresholdparsing while preserving valid legacy behaviorVerification
int()/float()parsing, signed-zero GPU IDs, and legacy--thresholdnumeric-token bypassesPYTHONPATH=src pytest tests/test_cli_thresholds.py tests/test_cli_service_commands.py tests/utilities/test_endpoint_validation.py -q->357 passedpre-commit run --all-files --show-diff-on-failure-> passedmkdocs build --strict-> exit 0, known Material/MkDocs 2.0 warning onlyPYTHONPATH=src pytest tests -q->1104 passed, 11 skippedLocal review
--thresholdbypass; fixed and re-reviewed.Summary by CodeRabbit
Bug Fixes
Documentation