Repository navigation
fix(bundled): add x-adcp-hoist to data-provider-signal-selector to fix codegen discriminator fabrication - #4867
Merged
Conversation
…x codegen discriminator fabrication data-provider-signal-selector.json appeared twice in the same bundled tasks-get-response.json after 3.1.0-beta.x added the result field (a union of all task response schemas). datamodel-code-generator fabricated a Literal['reuse'] discriminator value when the same discriminated oneOf was inlined twice, raising TypeError at import time and blocking the Python SDK. Mark the schema x-adcp-hoist:true so hoistMarkedSchemas() collapses both copies to a single $defs entry, replacing inline occurrences with $refs. The directive is stripped from bundled output; wire contract is unchanged. Adds a regression test covering the discriminated oneOf dedup case. Closes #4859 https://claude.ai/code/session_01KTXLjR1c5tGKPZQpSE8T4H
bokelley
marked this pull request as ready for review
May 20, 2026 18:05
Contributor
There was a problem hiding this comment.
Real fix, narrow surface. Uses an existing build-time mechanism (hoistMarkedSchemas) instead of inventing a new one, and keeps the bundled wire contract identical.
Things I checked
- Schema edit at
static/schemas/source/core/data-provider-signal-selector.json:6— single new key, no change todiscriminator,oneOf, or the threeselection_typebranches. - Bundler strip is real:
scripts/build-schemas.cjs:1473strips the marker on the canonical$defsentry, and the finalstripStrayMarkerssweep at:1515-1523recursively deletes any survivors. The existing test at:280-301already assertsx-adcp-hoistis absent from emitted output. - Fingerprint at
scripts/build-schemas.cjs:1381canonicalizes by recursive key-sort, so structurally equivalent inline copies collapse to one$defs.DataProviderSignalSelector. Same-title-different-shape is a hard error at:1450— fail-closed beats fail-open. - Regression test at
tests/build-schemas-hoist-marked.test.cjs:303-346reproduces the duplicated discriminated-oneOf pattern (first_use,second_use), asserts both collapse to a single$ref, asserts the discriminator survives, and asserts the marker is stripped. Right shape. - Changeset type
patchmatches wire impact — JSON Schema semantics on the bundled artifact are identical (inline →$refto$defs), no field renames/additions/removals on the wire. - No docs drift risk:
data-provider-signal-selectorhas no page underdocs/reference/**ormintlify-docs/reference/**; it's an internal building block referenced fromproduct.json:152and pulled throughasync-response-data.json's task-response union — exactly the fan-out path the changeset describes. ad-tech-protocol-expert: sound. Wire contract equivalent.x-adcp-hoistis established namespace (one of twox-adcp-*extension keys in use), not invented.code-reviewer: ready to push, no blockers.- CI: TypeScript Build, Server integration tests, changeset check, CodeQL, Semgrep — all green.
Follow-ups (non-blocking — file as issues)
- Other discriminated-
oneOfschemas instatic/schemas/source/core/(audience-selector,signal-targeting,publisher-property-selector,creative-asset,creative-manifest) share the same shape and are a latent class of this bug if they ever land in a multiplied fan-out path. Worth a one-shot audit that counts inline duplication instatic/schemas/dist/for each discriminated oneOf and flags any ≥2 withoutx-adcp-hoist. - Consider a bundler-side warning when a discriminated
oneOfis inlined ≥2 times without the marker — catches the rest of the class before it ships as a codegen TypeError. - Changeset body cites issue #4859 in prose but doesn't cross-link it. Test comment at
tests/build-schemas-hoist-marked.test.cjs:303does. Non-blocking.
LGTM. Follow-ups noted below.
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.
Summary
"x-adcp-hoist": truetodata-provider-signal-selector.jsonso the bundler deduplicates it via root$defsinstead of inlining it N timesoneOfdedup case (the exact pattern that triggered the bug)Problem
In 3.1.0-beta.x,
tasks-get-response.jsongained aresultfield referencingasync-response-data.json— a union of all task response schemas. When bundled,data-provider-signal-selector.json(a 3-branch discriminatedoneOfwithselection_typevaluesall,by_id,by_tag) appeared twice in the same bundled file.datamodel-code-generator0.56.1 fabricated aLiteral['reuse']discriminator value, raising:This blocked the entire Python SDK from importing.
Fix
Mark the schema
x-adcp-hoist: true. The bundler's existinghoistMarkedSchemas()function moves it to root$defs.DataProviderSignalSelectorand replaces all inline occurrences with{"$ref": "#/$defs/DataProviderSignalSelector"}. The directive is stripped from bundled output — wire contract is unchanged.Verified:
DataProviderSignalSelectorappears once in$defswithdiscriminator+oneOfintact andx-adcp-hoistabsent.Test plan
npm run build:schemas— 0 failures, 83 schemas bundlednpm run test:build-schemas-hoist-marked— 15/15 pass (14 existing + 1 new regression test)Fixes #4859
https://claude.ai/code/session_01KTXLjR1c5tGKPZQpSE8T4H
Generated by Claude Code