Skip to content

fix(types): add CreateMediaBuySubmittedResponse alias and fix handler return type#573

Closed
bokelley wants to merge 2 commits intomainfrom
claude/issue-570-create-media-buy-submitted-alias
Closed

fix(types): add CreateMediaBuySubmittedResponse alias and fix handler return type#573
bokelley wants to merge 2 commits intomainfrom
claude/issue-570-create-media-buy-submitted-alias

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented May 4, 2026

Closes #570

Summary

Three non-breaking SDK fixes for the async media-buy submitted branch, surfaced by the FastMCP validator misreport. Root cause (confirmed empirically): when a status='submitted' response is missing task_id, all three anyOf branches fail validation and jsonschema surfaces the deepest-path error — a misleading 'submitted' is not one of [...] enum mismatch on Branch 0 — rather than the actual required: task_id failure on Branch 2.

Changes:

  1. src/adcp/decisioning/handler.py — Fix PlatformHandler.create_media_buy return annotation from CreateMediaBuySuccessResponse to CreateMediaBuyResponse (the three-branch union). The previous annotation was a static lie that misled mypy users and code reviewers.
  2. src/adcp/types/aliases.py / __init__.py / adcp/__init__.py — Add CreateMediaBuySubmittedResponse = CreateMediaBuyResponse3 alias and export it from all three public surfaces so implementors have a semantic name instead of the internal Response3 suffix.
  3. schemas/cache/media-buy/create-media-buy-async-response-submitted.json — Add status (const "submitted") and task_id (string, required) to the standalone submitted schema. With response_mode="strict" the SDK's own validate_response() will now catch a missing task_id with a clear message.
  4. src/adcp/types/guards.py — Update CreateMediaBuyResponse local union alias to include the submitted branch; fix is_create_media_buy_success() to return False for submitted envelopes; add is_create_media_buy_submitted() TypeGuard.
  5. src/adcp/types/generated_poc/media_buy/create_media_buy_async_response_submitted.py — Bring the standalone generated class in sync with the updated schema (add status + task_id required fields).
  6. tests/fixtures/public_api_snapshot.json — Regenerated to include new exports.

Nit (not fixed, noted for reviewers): Four sibling standalone async-submitted schemas (update-media-buy, build-creative, get-products, sync-catalogs) remain underspecified in the same way. Canonical definitions in the bundled response schemas enforce required: [status, task_id] correctly; follow-up to bring standalone schemas to parity.

What tested

  • ruff check — passes on all modified files
  • mypy on modified files — no new errors (pre-existing errors in unrelated files unchanged)
  • pytest -k "media_buy or create_media or public_api" — 135 passed, 12 skipped

Pre-PR review

  • code-reviewer: approved after fixup iteration — blockers (snapshot stale, guards missing submitted branch, generated file not updated, top-level package missing export) all addressed; 1 nit noted (sibling schemas underspecified, out of scope for this PR)
  • ad-tech-protocol-expert: approved — task_id is unambiguously required per AdCP async task contract (confirmed via create-media-buy-response.json Branch 2 and comply-test-controller-request.json); additionalProperties: true correct and consistent with established pattern; change is non-breaking per spec

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/session_01MXKE7txstMT3B7aTctfXcZ


Generated by Claude Code

claude added 2 commits May 4, 2026 13:51
… return type

- Adds `CreateMediaBuySubmittedResponse = CreateMediaBuyResponse3` alias so
  implementors have a semantic name instead of the internal `Response3` suffix.
- Exports the alias from `adcp.types` (`__init__.py` + `__all__`).
- Fixes `PlatformHandler.create_media_buy` return annotation from
  `CreateMediaBuySuccessResponse` to `CreateMediaBuyResponse` (the full union)
  and updates the matching `cast()`.
- Adds `status` (const "submitted") and `task_id` (required string) to
  `create-media-buy-async-response-submitted.json` so the SDK's strict validator
  produces a clear missing-field error instead of propagating to FastMCP's
  misleading enum error.

Fixes #570

https://claude.ai/code/session_01MXKE7txstMT3B7aTctfXcZ
- Add is_create_media_buy_submitted() TypeGuard; fix is_create_media_buy_success()
  to return False for submitted envelopes (status=='submitted' check).
- Expand guards.py CreateMediaBuyResponse local union to include the submitted branch.
- Export is_create_media_buy_submitted from adcp.types and CreateMediaBuySubmittedResponse
  from the top-level adcp package alongside the success/error siblings.
- Update CreateMediaBuySubmitted generated class to include required status and task_id
  fields, bringing the standalone schema's Python representation in sync with the
  updated create-media-buy-async-response-submitted.json.
- Regenerate public API snapshot.

https://claude.ai/code/session_01MXKE7txstMT3B7aTctfXcZ
@bokelley
Copy link
Copy Markdown
Contributor Author

bokelley commented May 4, 2026

Superseded by #575 (merged today as f7960ed). The handler return-type widening + CreateMediaBuySubmittedResponse alias landed via that PR; closing as duplicate scope.

@bokelley bokelley closed this May 4, 2026
@bokelley
Copy link
Copy Markdown
Contributor Author

bokelley commented May 4, 2026

Acknowledged — confirmed #575 (f7960ed) covers the handler return-type widening and CreateMediaBuySubmittedResponse alias. No further action needed here.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastMCP output validator rejects 'submitted' status on CreateMediaBuyResponse oneOf

2 participants