fix(webhooks): reject unknown AdCP status in create_a2a_webhook_payload#605
Merged
fix(webhooks): reject unknown AdCP status in create_a2a_webhook_payload#605
Conversation
The builder previously fell back to ``TASK_STATE_UNSPECIFIED`` when the caller's status didn't match the AdCP→A2A mapping table. The wire normalizer then rewrote that to the literal string ``"unspecified"``, which is not a valid A2A v0.3 ``TaskState`` (the spec enum is submitted | working | input-required | completed | canceled | failed | rejected | auth-required | unknown). Buyer receivers validating against the schema reject the webhook — silent wire-level breakage. Raise ``ValueError`` at the builder boundary instead. The AdCP→A2A mapping is closed, so an unknown value is always a caller bug; failing loud beats producing a payload buyers will reject mid-delivery. Closes #603. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #603.
Summary
create_a2a_webhook_payloadpreviously fell back toTASK_STATE_UNSPECIFIEDfor any AdCP status not in its mapping table._normalize_a2a_task_state_to_v03then rewrote that to"unspecified"on the wire — not a valid A2A v0.3TaskState, so buyer receivers validating against the schema reject the webhook mid-delivery.ValueErrorat the builder boundary with the closed list of valid statuses. The AdCP→A2A mapping is closed; an unknown value is always a caller bug.tests/test_webhooks_to_wire_dict.pyasserts the new failure path.Test plan
test_a2a_unknown_status_raises_value_errorcovers the failure path.ruff check+mypyclean.🤖 Generated with Claude Code