fix(spur-cli)!: reject a zero token TTL and report overflow in seconds (follow-up to #716) - #727
Open
SumonAMD wants to merge 2 commits into
Open
fix(spur-cli)!: reject a zero token TTL and report overflow in seconds (follow-up to #716)#727SumonAMD wants to merge 2 commits into
SumonAMD wants to merge 2 commits into
Conversation
… (follow-up to ROCm#716) A zero TTL (e.g. `--ttl 0d`) parsed to 0 and, via the server's `ttl_secs.filter(|v| v > 0)`, collapsed to None -- a never-expiring token, the opposite of what the user asked for. Reject a non-positive duration in parse_ttl so both `token create` and `token user` fail clearly instead. Also reword the overflow error to report seconds vs seconds: it read "TTL 50000d exceeds 4294967295 seconds", mixing a days-denominated input with a seconds limit. Computing in u64 (which cannot overflow for a u32-bounded value) lets the message state the actual second count.
SumonAMD
requested review from
biluriuday,
sajmera-pensando,
sgopinath1,
shiv-tyagi and
yansun1996
as code owners
August 24, 2026 10:23
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
+ Coverage 79.36% 80.26% +0.90%
==========================================
Files 180 184 +4
Lines 82240 88647 +6407
==========================================
+ Hits 65266 71145 +5879
- Misses 16974 17502 +528 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #826
Follow-up to #716, addressing the two token nits from @sajmera-pensando.
Changes
parse_ttl("0d")returned0, and the server'sttl_secs.filter(|&v| v > 0)collapses0toNone— a never-expiringtoken, the opposite of intent.
parse_ttlnow rejects any non-positiveduration, so both
token createandtoken userfail clearly (they sharethis parser). Never-expiry stays available the documented way: omit
--ttl.TTL 50000d exceeds 4294967295 seconds, mixing a days input with a seconds limit. Computing inu64(can't overflow for a
u32-bounded value) lets the message state the actualsecond count:
TTL 50000d is 4320000000 seconds, over the 4294967295 second maximum.Tests
parse_ttl_rejects_zero(0,0d,0h,0s).cargo fmt/clippy -D warningsclean;spur-clisuite green.