Title: Framework wraps pydantic.ValidationError as INTERNAL_ERROR; should be INVALID_REQUEST · Issue #652 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: Framework wraps pydantic.ValidationError as INTERNAL_ERROR; should be INVALID_REQUEST · Issue #652 · adcontextprotocol/adcp-client-python
X Title: Framework wraps pydantic.ValidationError as INTERNAL_ERROR; should be INVALID_REQUEST · Issue #652 · adcontextprotocol/adcp-client-python
Description: Summary adcp.decisioning.dispatch._invoke_platform_method wraps any uncaught exception from a platform delegate as INTERNAL_ERROR with recovery="terminal". For genuine internals (database failures, NoneType bugs, etc.) that's correct. Bu...
Open Graph Description: Summary adcp.decisioning.dispatch._invoke_platform_method wraps any uncaught exception from a platform delegate as INTERNAL_ERROR with recovery="terminal". For genuine internals (database failures,...
X Description: Summary adcp.decisioning.dispatch._invoke_platform_method wraps any uncaught exception from a platform delegate as INTERNAL_ERROR with recovery="terminal". For genuine internals (database...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/652
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Framework wraps pydantic.ValidationError as INTERNAL_ERROR; should be INVALID_REQUEST","articleBody":"## Summary\n\n`adcp.decisioning.dispatch._invoke_platform_method` wraps any uncaught exception from a platform delegate as `INTERNAL_ERROR` with `recovery=\"terminal\"`. For genuine internals (database failures, NoneType bugs, etc.) that's correct.\n\nBut it also catches `pydantic.ValidationError`, which is **request-validation failure** — semantically `INVALID_REQUEST` with `recovery=\"correctable\"`. The current shape is technically wrong (terminal vs correctable, internal vs request) and the wire envelope on A2A specifically degrades to a generic `\"Task failed\"` message that strips the field information a buyer needs to fix the request.\n\n## Repro\n\nA buyer sends an update_media_buy patch with a field shape that fails the platform's stricter request schema (e.g., the platform extends the library type with `extra=\"forbid\"` and the buyer includes an extra field, or a type mismatch in a nested object). The delegate calls `RequestModel.model_validate(patch)`, Pydantic raises `ValidationError`, no caller catches it.\n\nWire result on A2A: `\"Task failed\"` (no `adcp_error.code`, no `field`, no recovery hint).\nWire result on MCP: `INTERNAL_ERROR: \"Platform method 'update_media_buy' raised ValidationError\"` (terminal recovery — wrong; buyer can correct the payload).\n\n## Proposed framework behavior\n\nIn `_invoke_platform_method` (or wherever the catch-all wrapping lives), distinguish `pydantic.ValidationError` from generic `Exception`:\n\n```python\nexcept pydantic.ValidationError as exc:\n raise AdcpError(\n code=\"INVALID_REQUEST\",\n message=_first_error_message(exc),\n recovery=\"correctable\",\n field=_first_error_loc_as_dotted_path(exc),\n details={\"validation_errors\": exc.errors(include_url=False)},\n )\nexcept Exception as exc:\n raise AdcpError(code=\"INTERNAL_ERROR\", ..., recovery=\"terminal\")\n```\n\nThis matches the framework's own behavior on **request-body** validation failures (when the JSON body fails the library schema, the framework already emits the proper `INVALID_REQUEST` envelope). The bug is just that `ValidationError`s raised inside the delegate — typically from a seller's extended request schema — aren't routed the same way.\n\n## Workaround (already shipped seller-side)\n\nWe extended our `@translate_adcp_errors` decorator at `core/platforms/_delegate.py` to also catch `pydantic.ValidationError` and translate to `INVALID_REQUEST` before it escapes to the framework: bokelley/salesagent#330.\n\nEvery seller that extends `RequestModel` (which is the recommended pattern in the SDK docs — `LibraryX as ParentX; class X(ParentX): ...`) will hit this same gap. Fixing at the framework level prevents the eight-line-of-boilerplate-per-seller workaround.\n\n## Tests\n\nCross-transport contract test pattern that exercises real ASGI envelopes:\n\n```python\nimport httpx\nfrom core.main import build_app\n\nasync def test_validation_error_translates_to_invalid_request(transport):\n app = build_app(...)\n async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app)) as client:\n response = await client.post(transport_url, json=bad_request_body)\n adcp_error = extract_adcp_error_from_envelope(response, transport)\n assert adcp_error[\"code\"] == \"INVALID_REQUEST\"\n assert adcp_error[\"recovery\"] == \"correctable\"\n assert adcp_error[\"field\"] # populated from validation errors\n```\n\n(See https://github.com/bokelley/salesagent/pull/330 — `tests/integration/test_delegate_wire_envelope_cross_transport.py` — for a working version.)\n\n## Environment\n\n- `adcp` Python SDK: pinned per salesagent's `uv.lock` (2026-05-11)\n- AdCP spec: 3.0.9","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-11T07:10:24Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/652"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cadd3456-d483-1542-0ab1-ea8647c07805 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C974:3F4253:214C7A9:2C4F760:6B018730 |
| html-safe-nonce | da65811cec11d26486b9f68ef157a48550993b355fef030929b5dcd697d61f8d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTc0OjNGNDI1MzoyMTRDN0E5OjJDNEY3NjA6NkIwMTg3MzAiLCJ2aXNpdG9yX2lkIjoiNDg4MzY5MDM5MjE4MjE2MzI0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d907ced93311255f2fcf574e87d97a97103f431d22638633a979e930b73d9d8b |
| hovercard-subject-tag | issue:4418789262 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/652/issue_layout |
| twitter:image | https://opengraph.githubassets.com/922927ee92cee429b02f3870c9b5a610f626d8abc00d6a7bb92f662173780083/adcontextprotocol/adcp-client-python/issues/652 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/922927ee92cee429b02f3870c9b5a610f626d8abc00d6a7bb92f662173780083/adcontextprotocol/adcp-client-python/issues/652 |
| og:image:alt | Summary adcp.decisioning.dispatch._invoke_platform_method wraps any uncaught exception from a platform delegate as INTERNAL_ERROR with recovery="terminal". For genuine internals (database failures,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width