Conversation
…+ add Submitted alias The wire CreateMediaBuyResponse is a 3-branch anyOf union (success / error / submitted), but the SDK previously typed PlatformHandler.create_media_buy as returning only the success branch and exposed semantic aliases for only two of the three branches. Two SDK-side fixes: 1. PlatformHandler.create_media_buy is annotated `-> CreateMediaBuyResponse` (the union) and the internal cast() matches. The handoff path legitimately returns the Submitted envelope; the prior success-only annotation misrepresented the contract. 2. Add CreateMediaBuySubmittedResponse semantic alias (-> CreateMediaBuyResponse3, the status='submitted'+task_id branch) alongside the existing CreateMediaBuySuccessResponse / CreateMediaBuyErrorResponse aliases. Exported from adcp.types. Tests cover alias identity, model_validate of a spec-compliant submitted payload, the missing-task_id rejection path, and the handler return-type annotation. The submitted-branch payload validation fix (the actual FastMCP error trigger) belongs in salesagent; the schema tightening belongs in the spec repo. Both are filed separately. Closes #570 (partial — schema and platform fixes tracked separately). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Spec-repo follow-up filed for the third leg of the original triage plan (schema tightening on the submitted-branch file): adcontextprotocol/adcp#4077 |
|
Noted — adcontextprotocol/adcp#4077 logged as the spec-side follow-up for the submitted-branch schema tightening. No action needed on this PR's diff. Generated by Claude Code |
|
Thanks — adcontextprotocol/adcp#4077 logged for the spec-side tightening is a clean handoff. This PR's diff is ready for review as-is. Generated by Claude Code |
…e-export Submitted The local CreateMediaBuyResponse alias in guards.py was a stale 2-branch union (Success | Error). PlatformHandler.create_media_buy now returns the full 3-branch union including the async Submitted envelope, so callers running is_create_media_buy_success on a handler result would silently mis-classify the submitted branch. Changes: - guards.py: widen CreateMediaBuyResponse to include CreateMediaBuySubmittedResponse; add is_create_media_buy_submitted TypeGuard; update success/error guards to short-circuit on the submitted branch (it's neither sync success nor terminal error). - adcp/__init__.py: re-export CreateMediaBuySubmittedResponse alongside the existing Success/Error aliases. - tests: cover the new submitted guard (positive + success/error negatives); update public_api snapshot for the top-level re-export.
|
Pushed follow-up commit 1.
2. Top-level All checks green: |
|
Noted — Generated by Claude Code |
|
Acknowledged. Also updated the PR body — the "Notes for reviewer" section had a stale line saying the top-level Triaged by Claude Code Generated by Claude Code |
Summary
CreateMediaBuyResponseis a 3-branchanyOfunion (success / error / submitted), but the SDK previously typedPlatformHandler.create_media_buyas returning only the success branch and exposed semantic aliases for only two of the three branches. This PR ships the SDK-side type-system fixes:PlatformHandler.create_media_buyis now annotated-> CreateMediaBuyResponse(the union). The internalcast()matches. The handoff path legitimately returns the Submitted envelope, so the prior success-only annotation was misleading.CreateMediaBuySubmittedResponsesemantic alias added alongside the existingCreateMediaBuySuccessResponse/CreateMediaBuyErrorResponse. It maps toCreateMediaBuyResponse3(thestatus='submitted'+task_idbranch). Exported fromadcp.typesand re-exported from the top-leveladcppackage.tests/test_create_media_buy_response_types.pycovers alias identity,model_validateof a spec-compliant submitted payload, missing-task_idrejection, and the handler return-type annotation.tests/fixtures/public_api_snapshot.jsonupdated for the newadcp.typesand top-leveladcpexports.src/adcp/types/guards.py: widened the localCreateMediaBuyResponsealias to the full 3-branch union; addedis_create_media_buy_submittedTypeGuard; updated success/error guards to short-circuit on the submitted branch.Out of scope (filed separately)
The original FastMCP error reported in #570 was caused by a malformed Submitted-branch payload (missing
task_id) hitting jsonschema's deepest-error heuristic. The two underlying fixes belong elsewhere:task_idpopulated) when handing off to long-running tasks.create-media-buy-response.jsonso the validator's deepest-error path produces a useful message on submitted-branch failures.Closes #570(partial — schema and platform fixes tracked separately).Notes for reviewer
src/adcp/__init__.pyhas been updated to re-exportCreateMediaBuySubmittedResponseat the top level (added in54275f29).Earlier draft noted it was omitted — that's now resolved.schemas/cache/files were touched.Test plan
ruff check src/— All checks passedmypy src/adcp/— Success: no issues found in 783 source filespytest tests/ -v -k "media_buy or create_media_buy or public_api or type_aliases"— 184 passed, 5 skippedpytest tests/(full suite) — 4170 passed, 24 skipped, 1 xfailed