You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(types): request model account fields still return removed AccountReference RootModel #1087
Public AccountReference is the new composable union alias.
GetProductsRequest.model_fields["account"].annotation is still the generated outer RootModel type.
request.account is AccountReference(root=AccountReference1(...)), not AccountReferenceById.
The same stale annotation is present on make_versioned_base("3.1", "GetProductsRequest").
Expected
SDK request models that expose an account field should use the public composable union and return its concrete arms, consistent with the beta.9 migration contract in #1084. Otherwise adopter code must support both the new public union and the removed wrapper depending on whether it validates the field directly or through an SDK request model.
Context
This surfaced while applying the beta.9 object-union migration from #1084.
Classification: Bug Bucket(s): client (label not found in repo — flagged as gap) Status: ready-to-implement
What the experts said:
code-reviewer: Fix belongs in _ergonomic.py patching layer using BeforeValidator + model_rebuild(force=True), consistent with existing patterns; 20+ models affected means the generator script also needs updating; test assertions on .account type need revision
dx-expert: Inconsistency between direct-validation and request-model-field paths is a first-class DX breakage for beta.9 adopters — the migration guide from fix(types)!: expose object unions without RootModel #1084 sets an expectation that .account yields concrete arms, and any code that does isinstance(request.account, AccountReferenceById) silently fails with the current wrapper
My take: This is a clean follow-on to #1084 — the generated AccountReference RootModel was intentionally removed from the public surface but the request model field annotations were not updated to match. The fix is well-bounded once the pattern is established, and it should complete before beta.9 adoption widens.
Implementation scope:
Root cause:generated_poc/*/request.py files bind account to account_ref.AccountReference (the RootModel wrapper); the patching layer in _ergonomic.py does not override this field, so validation returns AccountReference(root=AccountReference1(...)) instead of the concrete arm.
Recommended fix: In src/adcp/types/_ergonomic.py (and its generator scripts/generate_ergonomic_coercion.py), add an account field patch for each affected request model using:
Then for each model: _patch_field_annotation(ModelClass, "account", _AccountReferenceUnion) followed by model_rebuild(force=True). Alternatively, centralise in _forward_compat.py as a second apply-at-import pass over the same model list — fewer generator changes but mixes concerns slightly.
make_versioned_base note: The make_versioned_base("3.1", "GetProductsRequest") path derives fields from the bundled JSON schema, not from runtime annotations, so it may not pick up the _ergonomic.py patch automatically — verify whether the versioned base shares the same class object or constructs a fresh one; a separate patch may be needed there.
Required checks:pytest tests/ (update any assertions that currently expect AccountReference(root=...) to expect the concrete arm), mypy src/, ruff check . + black --check ..
Non-breaking rationale: Wire format is unchanged. The behavior change (RootModel → concrete arm on .account) is part of the announced beta.9 migration contract from fix(types)!: expose object unions without RootModel #1084 (which was itself tagged !). Within 8.0.0b9, completing this migration is expected.
Activity
bokelley commentedon Aug 25, 2026
Triage
Classification: Bug
Bucket(s): client (label not found in repo — flagged as gap)
Status: ready-to-implement
What the experts said:
_ergonomic.pypatching layer usingBeforeValidator+model_rebuild(force=True), consistent with existing patterns; 20+ models affected means the generator script also needs updating; test assertions on.accounttype need revision.accountyields concrete arms, and any code that doesisinstance(request.account, AccountReferenceById)silently fails with the current wrapperMy take: This is a clean follow-on to #1084 — the generated
AccountReferenceRootModel was intentionally removed from the public surface but the request model field annotations were not updated to match. The fix is well-bounded once the pattern is established, and it should complete before beta.9 adoption widens.Implementation scope:
Root cause:
generated_poc/*/request.pyfiles bindaccounttoaccount_ref.AccountReference(the RootModel wrapper); the patching layer in_ergonomic.pydoes not override this field, so validation returnsAccountReference(root=AccountReference1(...))instead of the concrete arm.Recommended fix: In
src/adcp/types/_ergonomic.py(and its generatorscripts/generate_ergonomic_coercion.py), add anaccountfield patch for each affected request model using:Then for each model:
_patch_field_annotation(ModelClass, "account", _AccountReferenceUnion)followed bymodel_rebuild(force=True). Alternatively, centralise in_forward_compat.pyas a second apply-at-import pass over the same model list — fewer generator changes but mixes concerns slightly.Scope of affected models (~20+):
GetProductsRequest,CreateMediaBuyRequest,UpdateMediaBuyRequest,SyncCatalogsRequest,SyncAudiencesRequest,SyncEventSourcesRequest,GetMediaBuyDeliveryRequest,GetMediaBuysRequest,GetAccountFinancialsRequest,SyncGovernanceRequest,SyncAccountsRequest(two fields),ListAccountsRequest,ReportUsageRequest,ActivateSignalRequest,GetSignalsRequest,AcquireRightsRequest,UpdateRightsRequest, collection-domain requests, andListTasksRequest/GetTaskStatusRequest.make_versioned_basenote: Themake_versioned_base("3.1", "GetProductsRequest")path derives fields from the bundled JSON schema, not from runtime annotations, so it may not pick up the_ergonomic.pypatch automatically — verify whether the versioned base shares the same class object or constructs a fresh one; a separate patch may be needed there.Required checks:
pytest tests/(update any assertions that currently expectAccountReference(root=...)to expect the concrete arm),mypy src/,ruff check .+black --check ..Non-breaking rationale: Wire format is unchanged. The behavior change (RootModel → concrete arm on
.account) is part of the announced beta.9 migration contract from fix(types)!: expose object unions without RootModel #1084 (which was itself tagged!). Within8.0.0b9, completing this migration is expected.Triaged by Claude Code. Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Generated by Claude Code