Skip to content

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
ROCm:mainfrom
SumonAMD:fix/716-token-ttl-zero-guard
Open

fix(spur-cli)!: reject a zero token TTL and report overflow in seconds (follow-up to #716)#727
SumonAMD wants to merge 2 commits into
ROCm:mainfrom
SumonAMD:fix/716-token-ttl-zero-guard

Conversation

@SumonAMD

@SumonAMD SumonAMD commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #826

Follow-up to #716, addressing the two token nits from @sajmera-pensando.

Changes

  • Zero-TTL guard. parse_ttl("0d") returned 0, and the server's
    ttl_secs.filter(|&v| v > 0) collapses 0 to None — a never-expiring
    token, the opposite of intent. parse_ttl now rejects any non-positive
    duration, so both token create and token user fail clearly (they share
    this parser). Never-expiry stays available the documented way: omit --ttl.
  • Overflow message in seconds. It read TTL 50000d exceeds 4294967295 seconds, mixing a days input with a seconds limit. Computing in u64
    (can't overflow for a u32-bounded value) lets the message state the actual
    second count: TTL 50000d is 4320000000 seconds, over the 4294967295 second maximum.

Tests

  • New parse_ttl_rejects_zero (0, 0d, 0h, 0s).
  • Existing overflow / non-numeric / suffix tests unchanged and passing.
  • cargo fmt / clippy -D warnings clean; spur-cli suite green.

… (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.
@codecov-commenter

codecov-commenter commented Aug 24, 2026

Copy link
Copy Markdown

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SumonAMD SumonAMD changed the title fix(spur-cli): reject a zero token TTL and report overflow in seconds (follow-up to #716) fix(spur-cli)!: reject a zero token TTL and report overflow in seconds (follow-up to #716) Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue]: A zero token TTL (--ttl 0d) creates a never-expiring token instead of being rejected

2 participants