Skip to content

fix(webhooks): keep 3.2 challenge helpers backward compatible - #1936

Merged
bokelley merged 1 commit into
mainfrom
fix/webhooks-3.2-backcompat
Nov 21, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/webhooks-3.2-backcompat

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Why

#1897 (fix(webhooks)!: comply with AdCP 3.2 challenge schema) made the webhook challenge helpers require seller_agent_url and event_types, and made proof challenges require an RFC 9421 WebhookSender. Calls that worked on 9.6.2 now fail, so release-please proposes 10.0.0 from main (#1898). That release fails CI because of the version number itself: the generated-alias removal test and adcp-reporting-storage's adcp>=9.0.0,<10 pin. It would also outrank the 10.0.0bN betas on next, which track AdCP 3.3.

This PR makes #1897 backward compatible so main can ship it as 9.7.0.

What changes

create_webhook_challenge_payload, challenge_webhook_destination and WebhookSender.send_webhook_challenge accept seller_agent_url and event_types as optional again.

When you pass both, nothing changes from #1897. The payload is schema-validated, delivery_auth is bound, and an RFC 9421 sender is required. The new-argument code is untouched apart from the parameter defaults and a private rename of the payload builder.

When you omit both, you get 9.6.2's behaviour plus a DeprecationWarning that names what to pass and says both become required in 10.0. Only omitting them counts. The defaults are a private sentinel, not None, so an explicit None (say, from empty config) takes the 3.2 path and fails exactly as it does on main. The public annotations stay str / Sequence[str], as on main.

9.6.2 call Behaviour on this branch
create_webhook_challenge_payload(account_id=, subscriber_id=, challenge=) Returns the 9.6 four-field payload, with no 3.2 schema validation. Warns.
challenge_webhook_destination(..., sender=<RFC 9421 sender>) Sends the four-field challenge, RFC 9421-signed. Warns.
challenge_webhook_destination(..., authentication=<Bearer/HMAC>), no sender= Sends the four-field challenge with legacy Authorization: Bearer or X-ADCP-Signature headers. Warns about the missing fields and, separately, about the missing RFC 9421 sender.
sender.send_webhook_challenge(url=, account_id=, subscriber_id=, ...) on an RFC 9421 sender Sends the four-field challenge, signed. Warns.
the same on a Bearer, legacy-HMAC or Standard Webhooks sender Sends it with that sender's own non-RFC 9421 authentication. Warns about the missing fields and about the sender not using RFC 9421.

These 9.6.2 behaviours are unchanged: passing both sender= and authentication= without the new fields raises ambiguous_auth_mode (the error now suggests passing the new fields); passing neither raises sender_required; a non-RFC 9421 sender= to challenge_webhook_destination raises sender_auth_mode_mismatch.

New call shapes that were never valid on 9.6.2 raise TypeError instead of guessing what the caller meant:

  • omitting only one of seller_agent_url and event_types, which matches main's missing-argument TypeError
  • authentication= passed to create_webhook_challenge_payload or send_webhook_challenge without the new fields

Passing the new fields opts into the whole 3.2 contract, the RFC 9421 sender included. So challenge_webhook_destination(seller_agent_url=..., event_types=..., authentication=...) with no sender= still raises sender_required, as it does on main.

Also in this PR:

  • README.md and docs/handler-authoring.md describe each function's deprecated behaviour separately.
  • The 9.6 code paths live in _challenge_webhook_destination_v9_6 and WebhookSender._send_v9_6_webhook_challenge. Delete them in 10.0, together with the two compat test modules.

Release notes for 9.7.0

  • Old-style calls now emit DeprecationWarning. A single challenge_webhook_destination(..., authentication=...) call with no sender= can emit up to three: missing fields, no RFC 9421 sender, and the existing once-per-process PushNotificationConfig.authentication warning. Adopters running with warnings-as-errors (-W error, filterwarnings = error) will see these calls fail until they migrate.
  • The warnings point at the caller's line for a direct await. When the call runs inside an asyncio task (asyncio.gather, create_task), they are attributed to asyncio internals (asyncio/events.py), so module-based warning filters won't match them.

Release

Testing

  • tests/test_webhook_challenge_legacy_compat.py has 28 tests. Each legacy call shape gets one or more; they assert the 9.6 wire payload and auth headers, the DeprecationWarning text, and that the warning points at the caller's line. It also covers the TypeErrors, explicit None following the 3.2 path (invalid_configuration, sender_required, RFC 9421 rejection), and that the new-field path emits no warnings.
  • tests/test_webhook_challenge_v9_6_compat.py is v9.6.2's tests/test_webhook_challenge.py checked in verbatim (18 tests, all passing). It covers config URLs, non-2xx responses, sender client and hook rejection, host override, preflight error wrapping, policy=, the sender timeout default, and model-typed authentication.
  • fix(webhooks)!: comply with AdCP 3.2 challenge schema #1897's tests (tests/test_webhook_challenge.py, tests/conformance/signing/test_webhook_sender_e2e.py, tests/test_webhook_signing_capabilities.py) still pass, unchanged.
  • Checked locally: ruff, mypy (src + storage package), and pre-commit (black, ruff, mypy, adopter type-checks, bandit) on the changed files.
  • Full local suite (macOS): 19,035 passed, 2,874 skipped, 7 failed. The 7 failures also fail on clean origin/main in this sandbox: 6 tests/test_reporting_interop_* TypeScript-interop gates and test_reporting_production_harness.py::test_installed_cleanup_still_writes_evidence_when_pipe_draining_expires (PermissionError on process-group control). Linux CI is authoritative for those.

🤖 Generated with Claude Code

Release-As: 9.7.0

PR 1897 made create_webhook_challenge_payload, challenge_webhook_destination
and WebhookSender.send_webhook_challenge require seller_agent_url and
event_types, and made proof challenges require an RFC 9421 sender. That broke
calls that worked on 9.6.2, so the next main release would have been 10.0.0.

The adcp 9.6 call shapes work again and emit a DeprecationWarning:

- Omitting seller_agent_url and event_types builds and sends the 9.6
  four-field challenge.
- challenge_webhook_destination with authentication= and no sender= sends
  that challenge with legacy Bearer or HMAC-SHA256 headers, as 9.6 did.
- send_webhook_challenge on a sender that does not sign with RFC 9421 sends
  it with that sender's own authentication, as 9.6 did.

Passing seller_agent_url and event_types keeps the AdCP 3.2 behaviour from
PR 1897 unchanged: schema-validated payload, delivery_auth binding, and RFC 9421
signing required. The defaults are a private sentinel, so only omitting
both arguments selects the 9.6 shape; an explicit None takes the 3.2 path and
fails as it does on main. Omitting only one raises TypeError. adcp 10.0 makes
both arguments and the RFC 9421 sender required.

Release-As: 9.7.0
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — reintroduces adcp 9.6 webhook-challenge call shapes behind a private _UNSET sentinel, restoring the DR-0032/DR-0033 pathway-back that #1897 removed.

No blocking findings. The reviewer verified the load-bearing items:

  • src/adcp/webhooks.py (+397): 3.2 builder is the old create_webhook_challenge_payload body renamed to _build_webhook_challenge_payload unchanged; XOR guard _check_challenge_fields_passed_together fails-closed on a single arg; _send_legacy_webhook_challenge keeps SSRF protection via the validated URL and signs HMAC over the same compact-separator bytes it posts (no spaced-vs-compact drift).
  • Op-readiness: sender and legacy paths both thread the sender timeout / timeout_seconds through.
  • Semver: required→optional loosening is non-breaking; fix: + Release-As: 9.7.0 is the correct signal.
  • Pathway: DR-0032/DR-0033 deprecated-path handling present with comprehensive tests (28 + 18) covering every shape, the TypeErrors, and caller-line warning attribution.

Decision trace: no critical/high/medium findings (row 1 n/a); gated_paths false (row 2 n/a); high_risk false (rows 3/5 n/a); no medium findings (rows 4/8 n/a); no prior decision (row 6 n/a); no no-auto-approve team match (row 7 n/a). Falls through to row 9 → approve. Note: review_decision is REVIEW_REQUIRED, but with gated_paths false that does not gate approval.

Comment thread src/adcp/webhook_sender.py Resolved
@bokelley
bokelley merged commit 6a0fe06 into main Nov 21, 2026
47 checks passed
@bokelley
bokelley deleted the fix/webhooks-3.2-backcompat branch November 21, 2026 23:39
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