Skip to content

Canonicalization drops a trailing empty query, so /p? and /p produce the same signature base #979

Closed

Description

@KonstantinMirin

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

  1. added
    claude-triagingTriage routine is actively working on this issue (1-3 min)
    on Jul 28, 2026
  2. bokelley commented on Jul 28, 2026

    @bokelley
    Contributor

    Triage

    Classification: Bug
    Bucket(s): signing (note: signing label 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() in src/adcp/signing/canonical.py should 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 — urlsplit maps both /p? and /p to query == "" and urlunsplit emits no ? for an empty string, erasing the distinction. The fix scope is narrow: a "?" in url.split("#")[0] guard at the end of canonicalize_target_uri() (line 91 of src/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

  3. added
    bugSomething isn't working
    and removed
    claude-triagingTriage routine is actively working on this issue (1-3 min)
    on Jul 28, 2026
  4. added a commit that references this issue on Jul 29, 2026
    afa0454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions