Skip to content

Name the sub claim in structured-value decode errors - #558

Open
hakarrr wants to merge 1 commit into
Keats:masterfrom
hakarrr:fix-sub-claim-diagnostic
Open

hakarrr wants to merge 1 commit into
Keats:masterfrom
hakarrr:fix-sub-claim-diagnostic

Conversation

@hakarrr

@hakarrr hakarrr commented Nov 14, 2026

Copy link
Copy Markdown

Addresses #427.

An object or array in sub is rejected, but TryParse currently swallows the type error before serde_json has consumed that value. The resulting error can point at a comma or closing brace instead of identifying the claim.

Use a subject-specific visitor so map/sequence values fail immediately with a diagnostic naming the JWT sub claim. This is a diagnostic fix, not support for structured subjects. Scalar/null handling and public JWT decode acceptance stay unchanged; other claims and signature verification are untouched. Plain string subjects can now borrow from the input instead of allocating.

Added regressions for structured subjects in both claim orders, the scalar/null/string cases, and escaped strings. Checked a 432-case signed-token decode matrix against the base: success/rejection categories are unchanged.

Local checks:

  • Full suites with rust_crypto and aws_lc_rs: 114 passed each, including 4 doctests.
  • No-default-feature suites with each provider: 92 passed each, including 4 doctests.
  • Clippy (--all-targets -- -D warnings) with both providers and rustfmt: pass.
  • Rust 1.88 MSRV library tests with rust_crypto: 52 passed.

Wasm was not tested. The structured-value diagnostic regression fails on the unchanged base.

Reject structured sub values with a claim-specific serde diagnostic instead of a later comma/brace error. Keep scalar and null subject handling unchanged.

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
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