Skip to content

fix(client): do not replay unsafe scoped writes after a 401 (from #84) - #93

Merged
zeekay merged 1 commit into
mainfrom
g6/p0-client-401-idempotency
Nov 25, 2026
Merged

zeekay merged 1 commit into
mainfrom
g6/p0-client-401-idempotency

Conversation

@zeekay

@zeekay zeekay commented Nov 25, 2026

Copy link
Copy Markdown
Member

Audits and lands fork PR #84 on a first-party branch.

Changes

  • On HTTP 401 for a scoped Client, invalidate the cached Grant as before, then check Request::repeats() (shared with crates/client/src/http.rs) before reminting and replaying.
  • Replay-safe methods (GET, HEAD, PUT, DELETE) and idempotent POST/PATCH with a non-empty requestId continue to remint and retry once.
  • Unnamed POST/PATCH (or empty requestId) surface the 401 without replaying, while the invalidated grant ensures the next request mints a fresh token.

Verification

  • cargo test -p hanzo-client --locked: 3 unit + 23 contract + 8 retry tests passed
  • cargo clippy --locked --all-targets -- -D warnings: 0 warnings
  • cargo fmt -p hanzo-client -- --check: clean

Supersedes #84 (with full attribution to @DivyamTalwar).

Invalidate the cached scoped grant on HTTP 401 as before, but only remint
and replay when Request::repeats() permits it (replay-safe methods, or
POST/PATCH carrying a non-empty requestId). Unnamed POST/PATCH requests
surface the 401 instead of risking duplicate side effects, while ensuring
subsequent requests mint a fresh grant.

Co-authored-by: Divyam Talwar <[email protected]>

Co-authored-by: Hanzo Dev <[email protected]>
@zeekay
zeekay merged commit 21bb7ff into main Nov 25, 2026
1 check passed
@zeekay
zeekay deleted the g6/p0-client-401-idempotency branch November 25, 2026 10:18
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.

1 participant