fix(cli): validate cache TTL values - #594
Conversation
Reject malformed, negative, fractional, and unsafe --cache-ttl values before API construction, and document the option in the schema.\n\nFixes nansen-ai#591
Reject whitespace-only and repeated valueless --cache-ttl occurrences, and validate TTLs even when caching is disabled.
pr-reviewer Summary for #1daac2c✅ No issues found The code review completed successfully with no findings. Review effort: 2/5 (Simple) SummaryThis PR is a clean, well-scoped fix for Overall assessment: The new Token usage: 803 input, 3,236 output, 323,689 cache read, 25,530 cache write | Usage Guide New pushes are reviewed automatically with a 10-minute cooldown between reviews. To request a review at any time, comment |
There was a problem hiding this comment.
Auto-approved
This PR was automatically approved because:
- Claude recommends approval
- Claude assessed this as a moderate effort change
- The effort level is within the auto-approval threshold of 2
- No high or critical issues were detected
- Review comment contains non-blocking feedback
If you have any concerns, please request a manual review.
Return a clear INVALID_PARAMS error when --cache-ttl is supplied more than once, rather than stringifying the accumulated value array.
There was a problem hiding this comment.
Auto-approved
This PR was automatically approved because:
- Claude recommends approval
- Claude assessed this as a moderate effort change
- The effort level is within the auto-approval threshold of 2
- No high or critical issues were detected
If you have any concerns, please request a manual review.
Summary
Fixes #591.
--cache-ttlwas parsed withparseInt()and accepted negative, fractional, missing, non-finite, and unsafe-integer inputs. The option was also absent from the global command schema.Changes
--cache-ttloption--no-cachedisables effective cache readsINVALID_PARAMSerror before API construction or network activityschema.jsonThis PR intentionally covers only
--cache-ttl; the separate--retriesfix is tracked in #590.Regression proof
The final cache-TTL tests applied to current
mainbefore the fix:The valid
0andNumber.MAX_SAFE_INTEGERboundaries passed; malformed-value, valueless,--no-cacheconflict, and schema assertions failed.With this fix:
Real CLI verification:
The command ran with a fake API key, temporary HOME, and external network access disabled; no API client/network path was entered.
Full suite, run without the competing parallel suite that had caused unrelated trading-test timeouts:
Additional checks:
npm run lint— passedgit diff --check— passednpm pack --ignore-scripts --dry-run— passed; 85 package files, no tests includedCompatibility and risk
0continues to disable cache readsNumber.MAX_SAFE_INTEGERis accepted exactlyChecklist
npm test)src/schema.jsonupdated for the corrected global option contractREADME.mdupdated if new top-level commands or categories were added — none added.changeset/validate-cli-cache-ttl.md)