Description
Found while vendoring the complete AdCP 3.1.1 request-signing vector set (#975). Reproduction is a canonicalization.json case, currently strict-xfail.
Problem
A URL with a trailing ? and an empty query loses the ? during canonicalization.
| case | input | expected @target-uri |
actual |
|---|---|---|---|
trailing-empty-query-preserved |
https://seller.example.com/p? |
https://seller.example.com/p? |
https://seller.example.com/p |
Cause
canonicalize_target_uri() round-trips through urlsplit / urlunsplit:
return urlunsplit((scheme, netloc, path, parts.query, ""))urlsplit maps both /p? and /p to query == "", and urlunsplit emits no ? for an empty query. The distinction between "empty query" and "no query" is erased, so the two URLs canonicalize identically.
Why it matters
RFC 9421 §2.2.2 derives @target-uri from the absolute request target, where /p? and /p are distinct. A counterparty that preserves the trailing ? computes a different signature base than the SDK, and the signature fails to verify with no diagnostic beyond request_signature_invalid — the failure mode canonicalization.json exists to catch early.
Narrow, but it is a real divergence and the fix is contained: preserve the ? when the original URL had one, e.g. by checking for "?" in url after the authority rather than relying on urlunsplit to round-trip it.
Activity
bokelley commentedon Jul 28, 2026
Triage
Classification: Bug
Bucket(s): signing (note:
signinglabel is not in this repo — bucket recorded in comment only)Status: deferred
Blocked-on: #980 — resurfaces on merge.
PR #980 (by the same author, open as of today) vendors the complete AdCP 3.1.1 vector set and explicitly marks this case as a strict-xfail with a back-reference to this issue. The fix to
canonicalize_target_uri()insrc/adcp/signing/canonical.pyshould arrive in a follow-up PR after #980 merges, so the implementation PR can retire the xfail marker cleanly rather than landing against a test infrastructure that doesn't yet exist.My take: The root cause is confirmed —
urlsplitmaps both/p?and/ptoquery == ""andurlunsplitemits no?for an empty string, erasing the distinction. The fix scope is narrow: a"?" in url.split("#")[0]guard at the end ofcanonicalize_target_uri()(line 91 ofsrc/adcp/signing/canonical.py). Folding the code change into #980 is out of scope for that PR, which is explicitly test-only.Triaged by Claude Code. Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Generated by Claude Code
feat(signing): reject malformed authorities, convert IDN hosts to A-l…
fix(signing): preserve a trailing empty query in @target-uri
fix(signing): reject malformed authorities, convert IDN hosts to A-la…
fix(signing): preserve a trailing empty query in @target-uri
fix(signing): preserve a trailing empty query in @target-uri
fix(signing): reject malformed authorities, convert IDN hosts to A-la…
fix(signing): reject malformed authorities, convert IDN hosts to A-la…
fix(signing): preserve a trailing empty query in @target-uri
fix(signing): preserve a trailing empty query in @target-uri (#987)