Title: feat(testing): forward pre_validation_hooks through build_asgi_app (follow-up to #626) · Issue #651 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: feat(testing): forward pre_validation_hooks through build_asgi_app (follow-up to #626) · Issue #651 · adcontextprotocol/adcp-client-python
X Title: feat(testing): forward pre_validation_hooks through build_asgi_app (follow-up to #626) · Issue #651 · adcontextprotocol/adcp-client-python
Description: Problem (follow-up to #626) adcp.testing.build_asgi_app (PR #626) is the public test-harness builder we adopted in salesagent (replacing private _build_mcp_and_a2a_app / _apply_asgi_middleware imports). It accepts every production serve(...
Open Graph Description: Problem (follow-up to #626) adcp.testing.build_asgi_app (PR #626) is the public test-harness builder we adopted in salesagent (replacing private _build_mcp_and_a2a_app / _apply_asgi_middleware impo...
X Description: Problem (follow-up to #626) adcp.testing.build_asgi_app (PR #626) is the public test-harness builder we adopted in salesagent (replacing private _build_mcp_and_a2a_app / _apply_asgi_middleware impo...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/651
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(testing): forward pre_validation_hooks through build_asgi_app (follow-up to #626)","articleBody":"## Problem (follow-up to #626)\n\n`adcp.testing.build_asgi_app` (PR #626) is the public test-harness builder we adopted in salesagent (replacing private `_build_mcp_and_a2a_app` / `_apply_asgi_middleware` imports). It accepts every production `serve()` kwarg we needed — auth, asgi_middleware, context_factory, streaming_responses, allowed_hosts/origins, validation, etc. — but **not `pre_validation_hooks`**.\n\nEffect on adopters: in-process HTTP-shaped tests driven via `httpx.ASGITransport(app=build_asgi_app(...))` get a different validation surface than production. Pre-v3 buyer payloads (`buying_mode` omitted, bare-string `format_id`, missing `asset_type`) that production auto-defaults via `serve(pre_validation_hooks=...)` are rejected by `build_asgi_app`-driven tests. Tests pass on payloads that would have been coerced in prod; tests fail on payloads that prod accepts.\n\nWe hit this during salesagent's 5.0 migration. Our [code reviewer flagged it](https://github.com/bokelley/salesagent/pull/...) as IMPORTANT: \"Pre-v3 buyer shapes that production would auto-default to will not be auto-defaulted in tests. This means in-process HTTP-shaped tests can pass while production fails on the same payload, or vice versa.\"\n\n## Concrete divergence\n\n```python\n# Production:\nserve(\n router,\n pre_validation_hooks={\"get_products\": apply_buying_mode_default},\n ...\n)\n# Buyer payload {\"brand\": ...} (no buying_mode) → coerced to {\"brand\": ..., \"buying_mode\": \"brief\"} → validates.\n\n# Test:\napp = build_asgi_app(router, ...)\n# Same payload → ValidationError: \"buying_mode\" field required.\n```\n\nTests can't reach the production code path without re-implementing the coercion in test setup — which defeats the point of testing the production wiring.\n\n## Proposed fix\n\nAdd `pre_validation_hooks` to `build_asgi_app`'s signature, forwarded the same way `serve()` forwards it to `create_adcp_server_from_platform` or the underlying MCP server builder:\n\n```python\ndef build_asgi_app(\n platform: DecisioningPlatform,\n *,\n name: str = ...,\n # ... existing kwargs ...\n pre_validation_hooks: dict[str, Callable[[str, dict[str, Any]], dict[str, Any]]] | None = None,\n factory_kwargs: ...,\n) -> Any: ...\n```\n\nSymmetric with `serve()`. Forwards to whatever internal path `serve()` uses to install the hooks pre-dispatcher.\n\n## Why this matters\n\nThis is the second adopter friction point on `build_asgi_app` since 5.0 (the first was the [#618 pre-existing gap that the PR addressed](https://github.com/adcontextprotocol/adcp-client-python/pull/626)). Every kwarg `serve()` accepts that `build_asgi_app` doesn't accept is a place adopters either (a) lose production fidelity in tests, or (b) re-implement plumbing on the test side.\n\nFor salesagent, the workaround for now is documenting in `build_app()`'s docstring that pre-v3 wire fidelity is not preserved in in-process tests — adopters who need pre-v3-shape testing must use the production `serve()` path or pre-shape payloads themselves. Worth fixing properly upstream.\n\n## Files\n\n- Our `build_app()`: [bokelley/salesagent core/main.py](https://github.com/bokelley/salesagent/blob/main/core/main.py) — search for `build_asgi_app`. Currently drops `pre_validation_hooks` with a comment justifying the divergence; that comment can be removed once this lands.\n\n## Related\n\n- #626 (closed) — shipped the public `build_asgi_app`. This is a per-kwarg gap, not a regression.\n- #629 — the `pre_validation_hooks` mechanism this would forward.\n- Our composition issue [#645](https://github.com/adcontextprotocol/adcp-client-python/issues/645) (TenantRegistry → serve adapter) and #647 (per-request public_url) — same pattern of \"SDK shipped the production primitive, but the test/composition surface lags.\"\n","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-11T07:05:16Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/651"}
| 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:6b7d03c1-e8bc-a065-56d1-5660678a4167 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E02:3F8AB1:286E249:335935F:6B0184F3 |
| html-safe-nonce | 13c042357916e7720fda5f30606ec421021c3ccba003c489f8bb789b6487d8c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTAyOjNGOEFCMToyODZFMjQ5OjMzNTkzNUY6NkIwMTg0RjMiLCJ2aXNpdG9yX2lkIjoiOTEwNzUwOTA5MzkwNzY2MjA2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e3fdf4d39b286b9624b55bd34ede4a4feba4a2f01d338ba796ebb8a3834a32f0 |
| hovercard-subject-tag | issue:4418759039 |
| 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/651/issue_layout |
| twitter:image | https://opengraph.githubassets.com/744301431f2923e91bf1dc601b8aabc4fd447ca5f127c4406c18f6529ce628ff/adcontextprotocol/adcp-client-python/issues/651 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/744301431f2923e91bf1dc601b8aabc4fd447ca5f127c4406c18f6529ce628ff/adcontextprotocol/adcp-client-python/issues/651 |
| og:image:alt | Problem (follow-up to #626) adcp.testing.build_asgi_app (PR #626) is the public test-harness builder we adopted in salesagent (replacing private _build_mcp_and_a2a_app / _apply_asgi_middleware impo... |
| 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