Repository navigation
Description
Summary
On 8.0.0 a seller has two ways to reject unknown request fields. Neither works for a seller built on LazyPlatformRouter that serves 3.1+ buyers.
- Subclass re-validation is skipped behind routers.
_coerce_params_to_platform_type(adcp/decisioning/dispatch.py:1306-1389) re-validates the library request (extra='allow') through a stricter subclass annotation on the platform method. Router delegates are synthesized asasync def _delegate(*args, **kwargs)(adcp/decisioning/platform_router.py:596,:1085,:1330). The coercion stops atVAR_POSITIONAL(dispatch.py:1352-1356). The child platform's annotation is never consulted, because the delegate calls the child directly. ValidationHookConfig(unknown_fields="reject")(Server: add configurable unknown-field policy before tool argument coercion #858) rejects the version envelope._allowed_top_level_fields(adcp/server/mcp_tools.py:2865-2892) takes the allowed set from the request schema'sproperties. The bundled 3.1 and 3.2get-products-request.jsondon't listadcp_version/adcp_major_versionthere. Every buyer that negotiates a version is rejected.
Reproduction (adcp 8.0.0)
Router bypass:
import asyncio
import logging
import warnings
warnings.simplefilter("ignore")
logging.disable(logging.CRITICAL)
from pydantic import ConfigDict
from adcp.decisioning import DecisioningCapabilities, DecisioningPlatform, LazyPlatformRouter, SingletonAccounts
from adcp.decisioning.serve import create_adcp_server_from_platform
from adcp.server.base import ToolContext
from adcp.types import GetMediaBuysRequest
CAPS = DecisioningCapabilities(specialisms=["sales-non-guaranteed"], supported_billing=["operator"])
ACCOUNTS = SingletonAccounts(account_id="acct", metadata_factory=lambda: {"tenant_id": "t1"})
class StrictGetMediaBuysRequest(GetMediaBuysRequest):
model_config = ConfigDict(extra="forbid")
class Seller(DecisioningPlatform):
capabilities = CAPS
accounts = ACCOUNTS
def get_media_buys(self, req: StrictGetMediaBuysRequest, ctx):
return {"media_buys": [], "received": type(req).__name__}
def get_products(self, req, ctx): return {"products": []}
def create_media_buy(self, req, ctx): raise NotImplementedError
def update_media_buy(self, media_buy_id, patch, ctx): raise NotImplementedError
def sync_creatives(self, req, ctx): raise NotImplementedError
def get_media_buy_delivery(self, req, ctx): raise NotImplementedError
router = LazyPlatformRouter(accounts=ACCOUNTS, factory=lambda tenant_id: Seller(), capabilities=CAPS)
direct, _, _ = create_adcp_server_from_platform(Seller())
routed, _, _ = create_adcp_server_from_platform(router)
async def call(label, handler):
req = GetMediaBuysRequest.model_validate({"nonsense_field": "x"}) # library model: extra='allow'
try:
result = await handler.get_media_buys(req, ToolContext())
print(f"{label}: accepted, platform received {result.get('received')}")
except Exception as exc:
print(f"{label}: {exc.code} | {exc}")
async def main():
await call("direct platform ", direct)
await call("LazyPlatformRouter ", routed)
asyncio.run(main())direct platform : INVALID_REQUEST | AdcpError[INVALID_REQUEST / correctable]: Request validation failed for 'get_media_buys': Extra inputs are not permitted (field: 'nonsense_field')
LazyPlatformRouter : accepted, platform received GetMediaBuysRequest
Unknown-field policy:
import asyncio, warnings, logging
warnings.simplefilter("ignore"); logging.disable(logging.CRITICAL)
from adcp.server import ADCPHandler
from adcp.server.mcp_tools import create_tool_caller
from adcp.validation.client_hooks import ValidationHookConfig
class Seller(ADCPHandler):
async def get_products(self, params, context=None):
return {"products": []}
async def main():
call = create_tool_caller(Seller(), "get_products", validation=ValidationHookConfig(unknown_fields="reject"))
base = {"buying_mode": "brief", "brief": "video"}
for env in ({}, {"adcp_version": "3.2"}, {"adcp_major_version": 3}, {"nonsense_field": 1}):
try:
await call({**base, **env}); print(env, "-> accepted")
except Exception as exc:
e = exc.errors[0]; print(env, "->", e.code, e.field, "|", e.message)
asyncio.run(main()){} -> accepted
{'adcp_version': '3.2'} -> INVALID_REQUEST adcp_version | Unexpected top-level field 'adcp_version' for get_products
{'adcp_major_version': 3} -> INVALID_REQUEST adcp_major_version | Unexpected top-level field 'adcp_major_version' for get_products
{'nonsense_field': 1} -> INVALID_REQUEST nonsense_field | Unexpected top-level field 'nonsense_field' for get_products
Why an adopter hits this
Embedded Sales Agent serves every tenant through LazyPlatformRouter and rejects unknown fields in dev/CI so contract drift fails loudly. Neither SDK path works, so ESA rebuilds it in a pre-validation hook: _strict_request_fields_by_tool and _with_dev_unknown_field_rejection in core/main.py, about 120 LOC. That includes a hand-kept field list for list_creatives, and its field sets come from ESA's local models, which (unlike the schemas) include adcp_version / adcp_major_version. The rejection is also top-level only. Nested extra='forbid' models and field validators on ESA's request subclasses still never run behind the router. The comment on _delegate_get_products in core/platforms/_delegate.py records why.
Ask
- Always allow the protocol envelope (
adcp_version,adcp_major_version, and anything elsedetect_wire_versionconsumes) in_allowed_top_level_fields, or strip it before the policy runs. - Make router delegates carry the child's annotation: resolve the tenant platform first, then run
_coerce_params_to_platform_typeagainst the child method. Or expose a per-routerrequest_models={tool: Model}that the dispatcher re-validates through.
Activity
bokelley commentedon Oct 2, 2026
Triage
Classification: Bug (two independent defects)
Bucket(s): handlers, validation (labels not found in repo — noted for label gap)
Status: ready-to-implement
Milestone: omitted
What the experts said:
detect_wire_version's canonical source, not a standalone hardcode.My take: Both bugs are confirmed, non-breaking correctness fixes. No disagreement between experts, no security surface, and clear reproduction steps make this ready to implement without further clarification.
Implementation scope:
platform_router.py+dispatch.py: In the synthesized_delegate, after resolving the child platform, extractparamsfromargs[0](positional path) orkwargs(arg-projector path), call_coerce_params_to_platform_type(child_method, params, method_name), then reconstructargs(replaceargs[0]) orkwargswith the coerced object before forwarding to the child. Both calling conventions must be covered. Key files:src/adcp/decisioning/platform_router.py:596,1085,1330andsrc/adcp/decisioning/dispatch.py:1352-1356.mcp_tools.py: In_allowed_top_level_fields, unconditionally union the known wire-envelope field names (adcp_version,adcp_major_version) into the returned set. Derive this list fromadcp.validation.envelope/ the canonical source consumed bydetect_wire_versionrather than hardcoding independently, so future envelope fields are covered automatically. Also verify whether AdCP 3.2+ introduces additional envelope fields (e.g. signing nonce) sharing the same gap. Key file:src/adcp/server/mcp_tools.py:2865-2892.PlatformRouter/LazyPlatformRouter+ strict subclass annotation →INVALID_REQUESTon unknown field, valid request routes normally; (b)ValidationHookConfig(unknown_fields="reject")+ request withadcp_version→ accepted;adcp_major_version→ accepted; genuine unknown field → still rejected;STRIPmode preserves envelope fields.INVALID_REQUEST); Bug 2 fix converts incorrect rejections into correct acceptances. No public API removed or renamed.Triaged by Claude Code. Session: https://claude.ai/code/session_01EsqDA1d1kM9ny2RpeTWpzG
Generated by Claude Code