Repository navigation
fix(client): flatten v3 manifest assets to v2.5 single-asset payload in adaptSyncCreativesRequestForV2 - #1118
Merged
bokelley merged 4 commits intoMay 1, 2026
Conversation
…in adaptSyncCreativesRequestForV2 Fixes #1116. The adapter was leaking the role-keyed v3 manifest shape through to v2.5 servers, causing every adapted creative to fail the creative-asset oneOf. Now extracts the primary role asset; multi-role manifests emit a console.warn and forward the first role only. https://claude.ai/code/session_012XP8dKgUqa37s61cDcm996
…s tests - Fix entries[0] blindly selecting potentially non-asset first role; now uses find() to pick the first entry whose value carries asset_type, with a malformed-all-roles fallback that passes through verbatim. - Add 3 tests for non-binary v3 status values (pending_review, processing, archived) documenting the intentional silent-drop behavior. - Add test for non-asset-first-role manifest to guard the fix. https://claude.ai/code/session_012XP8dKgUqa37s61cDcm996
bokelley
marked this pull request as ready for review
May 1, 2026 09:14
3 tasks done
bokelley
added a commit
that referenced
this pull request
May 1, 2026
…1150 (#1172) Client-side response validation previously defaulted to strict in dev/test and warn in prod. With #1137's version-pinned validator, that asymmetry made v2.5 sellers' perfectly valid v2.5-shaped responses strictly fail in dev/test even though they'd succeed in prod — buyers got `0 products` with the actual data discarded. Flip the dev/test default to match prod: warn everywhere. Drift still surfaces via `result.debug_logs` (the channel #1133 plumbed). Buyers who want hard-stop validation opt in via `validation: { responses: 'strict' }` — explicit config still wins. Server-side `createAdcpServer` is unchanged — handler-side validation stays strict in dev/test/CI to catch our own handler-output bugs. Side fix: update `adapter-v2-5-conformance.test.js` to match the post-#1118 sync_creatives drift surface; pinned the failing pointer to `/creatives/0/assets/asset_type` and noted that #1118's flatten may have inverted the v2.5 schema expectation (creative-asset.json declares `assets` as a role-keyed manifest object, same as v3 — the flat shape #1118 now emits fails patternProperties validation). Worth a follow-up to confirm the seller-runtime expectation vs the spec. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
May 1, 2026
PR #1118 (a6865c3, "flatten v3 manifest assets to v2.5 single-asset payload") closed the primary manifest-shape leak but the conformance fixture's expected_failures.pointers wasn't updated to match the new drift signature. Fixture comment literally says "If the failure mode changed, update or remove this fixture." Adapter now flattens role-keyed manifest to a single-asset shape, but the flattened shape's flat keys (asset_type, url, width, height, duration_ms) still don't satisfy v2.5's single-asset-payload oneOf — v2.5 expects a different envelope. Pin the fixture to the post-#1118 drift signature so a follow-up adapter fix surfaces as an unexpected pass. Unrelated to this PR's #1144/#1145 work but blocking CI. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
pushed a commit
that referenced
this pull request
May 1, 2026
…le-keyed shape Closes #1173 PR #1118's flatten step extracted the first role's asset and passed a flat payload ({ asset_type, url, … }) to v2 servers. The v2.5 creative-asset.json schema uses patternProperties keyed by role string — the same manifest shape as v3 — so the flat output failed schema validation on every field with "must be object" errors at /creatives/0/assets/asset_type and siblings. Removes isManifestShape + the flatten branch from adaptCreativeForV2; assets now pass through verbatim. Updates the unit tests to assert manifest pass-through instead of flatten. Flips the sync_creatives fixture in adapter-v2-5-conformance.test.js from expected_failures to a standard passing assertion. https://claude.ai/code/session_012FDPBrTs3LfmW9MHuJSAYn
This was referenced May 1, 2026
bokelley
added a commit
that referenced
this pull request
May 1, 2026
#1144) (#1165) * feat(decisioning): AccountToolContext + refreshToken hook (#1145 Gaps 1+2) Gap 1: thread resolved Account<TCtxMeta> into getAccountFinancials via new AccountToolContext<TCtxMeta> (strict superset of ResolveContext). Adopters read ctx.account.ctx_metadata directly — no re-resolve from req.account. Resolves 7-adapter pain point (snap, meta, amazon, citrusad, criteo, pinterest, universalads) that stubbed getAccountFinancials to UNSUPPORTED_FEATURE because the v6 surface didn't thread Account through. Breaking for v6.x adopters who already implemented getAccountFinancials — update the second arg type. Resolve null surfaces ACCOUNT_NOT_FOUND (terminal) before the platform method runs. Gap 2: optional AccountStore.refreshToken(account, 'auth_required') mid-request token refresh. When a platform method throws AdcpError({ code: 'AUTH_REQUIRED' }), framework calls the hook, mutates account.authInfo.token, retries the call exactly once. In-flight scope only — refreshed tokens not echoed to buyer. Refresh-hook failure surfaces correctable AUTH_REQUIRED so buyer re-links via UI. Wired into getAccountFinancials dispatch; broader site wiring is incremental. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(storyboard): peer_substitutes_for declared-substitute opt-in (#1144) Stateful steps can declare peer_substitutes_for: <step_id> | <step_id>[] on the substitute step to opt into substitute-aware cascade deferral. When a stateful step skips with missing_tool / missing_test_controller AND a peer in the same phase declares it as a substitute, the runner defers the cascade decision to phase end and waives it iff the declared substitute passes. Contract hygiene + diagnostic improvement, NOT a fix for the 1/9/0 adopter cluster (those are wrong-storyboard / phase-independence issues tracked separately at adcp-client#1161). Tightens the implicit "phase membership = substitutability" rule the F6 fix relied on so future storyboards with multi-stateful-step phases can't silently rescue non-substitutes. Cascade-detail messages name the declared substitute that didn't pass so 1/9/0 reports show the substitution chain. Loader rejects cross-phase references, self-references, and non-stateful targets at parse time. Legacy not_applicable any-peer rescue unchanged. Companion spec change required at adcontextprotocol/adcp (filed as #3734) before any storyboard exercises the new path. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(decisioning): address review feedback on PR #1165 Security: refresh-failure error message no longer echoes upstream exception text on the wire. Inner exceptions routinely embed refresh- token prefixes, internal hostnames, and OAuth provider error codes; buyer gets a fixed message + correctable recovery, adopters log details server-side. (security-reviewer finding) Correctness: AuthPrincipal.expiresAt? added so the framework's write of the refreshed expiry is reachable to adopters reading the resolved Account. Previously cast to a phantom field. (code-reviewer finding) Docs: - AccountToolContext docstring clarifies it is getAccountFinancials- only and explicitly does NOT apply to reportUsage (multi-account- per-row by wire shape). (protocol-reviewer finding) - refreshToken docstring documents Account-object identity contract (cached Account = bug; return fresh from resolve()), concurrency expectations (adopter coalesces, framework does not), wire-leak policy on refresh failure, and the open-string-union convention for the reason param. - Removed orphaned duplicate doc comment block above ResolvedAuthInfo. (code-reviewer nit) Tests added: - Retry that also throws AUTH_REQUIRED bubbles without a third call (refresh fires exactly once). (code-reviewer gap) - Refresh-failure wire envelope does NOT echo upstream OAuth error text — asserts inner refresh-token prefix, internal hostname, and provider error code are scrubbed. (security-reviewer gap) - Successful refresh writes expiresAt onto account.authInfo (proves the new field is reachable end-to-end). - Loader validation: self-reference, empty-string array entry, non-stateful target, non-stateful substitute — all rejected at parse time. (code-reviewer gap: 4 of 5 rules previously untested) Deferred (raised in review, not blocking merge): - peer_substitutes_for direction vs. AdCP cross-step grammar (provides_state_for vs. peer_substitutes_for naming) — raise on adcp#3734 spec discussion. - RefreshConfig<TCtxMeta> generic propagation so refresh hooks see typed ctx_metadata — minor; follow-up issue. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(v2-adapter): update sync_creatives drift fixture post #1118 PR #1118 (a6865c3, "flatten v3 manifest assets to v2.5 single-asset payload") closed the primary manifest-shape leak but the conformance fixture's expected_failures.pointers wasn't updated to match the new drift signature. Fixture comment literally says "If the failure mode changed, update or remove this fixture." Adapter now flattens role-keyed manifest to a single-asset shape, but the flattened shape's flat keys (asset_type, url, width, height, duration_ms) still don't satisfy v2.5's single-asset-payload oneOf — v2.5 expects a different envelope. Pin the fixture to the post-#1118 drift signature so a follow-up adapter fix surfaces as an unexpected pass. Unrelated to this PR's #1144/#1145 work but blocking CI. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(runner): opt regression-detector tests into strict response validation Both tests assert the inverse property — a known-broken adapter MUST be detected. PR #1172 changed the default from strict to warn, which caused validateResponseSchema to return {valid:true} on any schema failure, making the regressed adapter appear conformant. Adding validation:{responses:'strict'} restores the abort-and-fail path these tests depend on. https://claude.ai/code/session_01NoBpco1uzkHV4Ei9TFoR49 --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
pushed a commit
that referenced
this pull request
May 1, 2026
…le-keyed shape Closes #1173 PR #1118's flatten step extracted the first role's asset and passed a flat payload ({ asset_type, url, … }) to v2 servers. The v2.5 creative-asset.json schema uses patternProperties keyed by role string — the same manifest shape as v3 — so the flat output failed schema validation on every field with "must be object" errors at /creatives/0/assets/asset_type and siblings. Removes isManifestShape + the flatten branch from adaptCreativeForV2; assets now pass through verbatim. Updates the unit tests to assert manifest pass-through instead of flatten. Flips the sync_creatives fixture in adapter-v2-5-conformance.test.js from expected_failures to a standard passing assertion. https://claude.ai/code/session_012FDPBrTs3LfmW9MHuJSAYn
bokelley
pushed a commit
that referenced
this pull request
May 1, 2026
Closes #1173. Per v2.5 schema (`adcontextprotocol/[email protected]`, `creative-asset.json`), `assets` uses the same role-keyed manifest shape as v3 — `{ [role: string]: AssetInstance }`. PR #1118's flatten step collapsed v3's manifest into a single asset payload, which fails v2.5 schema validation on every shape because v2.5 expects manifest, not flat. Two changes vs the original revert in this PR: - The adapter passes the manifest through (vs flattening). The role-keyed shape is identical between v3 and v2.5; no conversion needed. - The adapter strips `asset_type` from each role's inner asset value. v3 uses `asset_type` (e.g. `"video"`) as an embedded shape discriminator; v2.5 uses the role KEY as the discriminator and v2.5's asset variants do not declare `asset_type`. Leaving it in produces ambiguous oneOf matches at strict v2.5 sellers. Conformance fixture for sync_creatives moves from `expected_failures` to a passing assertion. Wonderstruck-shaped sellers that expected the flat payload will start receiving manifest after this lands; tracked separately. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
pushed a commit
that referenced
this pull request
May 1, 2026
Closes #1173. Per v2.5 schema (`adcontextprotocol/[email protected]`, `creative-asset.json`), `assets` uses the same role-keyed manifest shape as v3 — `{ [role: string]: AssetInstance }`. PR #1118's flatten step collapsed v3's manifest into a single asset payload, which fails v2.5 schema validation on every shape because v2.5 expects manifest, not flat. Two changes vs the original revert in this PR: - The adapter passes the manifest through (vs flattening). The role-keyed shape is identical between v3 and v2.5; no conversion needed. - The adapter strips `asset_type` from each role's inner asset value. v3 uses `asset_type` (e.g. `"video"`) as an embedded shape discriminator; v2.5 uses the role KEY as the discriminator and v2.5's asset variants do not declare `asset_type`. Leaving it in produces ambiguous oneOf matches at strict v2.5 sellers. Conformance fixture for sync_creatives moves from `expected_failures` to a passing assertion. Wonderstruck-shaped sellers that expected the flat payload will start receiving manifest after this lands; tracked separately. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
May 1, 2026
…#1174) Closes #1173. Per v2.5 schema (`adcontextprotocol/[email protected]`, `creative-asset.json`), `assets` uses the same role-keyed manifest shape as v3 — `{ [role: string]: AssetInstance }`. PR #1118's flatten step collapsed v3's manifest into a single asset payload, which fails v2.5 schema validation on every shape because v2.5 expects manifest, not flat. Two changes vs the original revert in this PR: - The adapter passes the manifest through (vs flattening). The role-keyed shape is identical between v3 and v2.5; no conversion needed. - The adapter strips `asset_type` from each role's inner asset value. v3 uses `asset_type` (e.g. `"video"`) as an embedded shape discriminator; v2.5 uses the role KEY as the discriminator and v2.5's asset variants do not declare `asset_type`. Leaving it in produces ambiguous oneOf matches at strict v2.5 sellers. Conformance fixture for sync_creatives moves from `expected_failures` to a passing assertion. Wonderstruck-shaped sellers that expected the flat payload will start receiving manifest after this lands; tracked separately. Co-authored-by: Claude <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1116
Summary
adaptSyncCreativesRequestForV2was a thin v3-prefix-stripper: it strippedaccount,adcp_major_version,catalogs, and convertedstatus→approved, but spread...reston each creative, leaking the v3assetsmanifest shape ({ role: { asset_type, url, … } }) through to v2.5 servers unchanged. v2.5'screative-asset.jsonschema expects a single asset payload discriminated byasset_type; every adapted creative therefore failed theoneOfcheck and was rejected by strict v2.5 sellers.This PR rewrites the per-creative adapter to detect and flatten manifest-shaped assets:
{ video: { asset_type: 'video', … } }) → extract the single value, pass as flatassetsasset_type(skipping any non-asset roles), emitconsole.warnnaming the discarded roles, keep originalcreative_idintact (no phantom suffix IDs)asset_typeat top level) → pass through unchangedassetsfield / empty manifest / all-malformed roles → defensive pass-through; let the server validateWhat was tested
npx tsc --project tsconfig.lib.json— clean (pre-existing TS2688/TS5107 onmainunchanged)npx prettier --check— cleannode --test test/lib/sync-creatives-adapter.test.js— 26/26 pass (new dedicated suite)node --test test/lib/request-validation.test.js— 9 pre-existing failures unchanged; the newdeepStrictEqualassertion oncreatives[0].assetspassesPre-existing failures in
request-validation.test.jsare unrelated infrastructure issues present onmain(confirmed viagit stashbaseline).Pre-PR review
find(); test guards the fix); changeset present; nits noted in summary.flatMap.Session: https://claude.ai/code/session_012XP8dKgUqa37s61cDcm996
Generated by Claude Code