Conversation
…one on request types (#641) Omitting canceled from UpdateMediaBuyRequest or PackageUpdate previously defaulted to True (datamodel-codegen const:true handling), silently canceling the media buy on every routine update. Adds fix_canceled_literal_defaults() to post_generate_fixes.py, widens 4 request-type emissions to Literal[True] | None = None, and adds 11 behavioral tests. https://claude.ai/code/session_013iJiiNZi9aBGFawGKUNiGw
e458dda to
06acaea
Compare
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 #641
canceled: Literal[True] = TrueonUpdateMediaBuyRequestandPackageUpdatewas adatamodel-codegenmisfire from"const": trueboolean schema properties. Any buyer who omitted the field — e.g. a routine budget or pacing update — silently triggered irreversible media buy cancellation via the Pydantic default. This PR fixes all four request-type emissions by addingfix_canceled_literal_defaults()toscripts/post_generate_fixes.py, which rewrites the annotation toLiteral[True] | Noneand the default to= None. Wire semantics are preserved: the field still only acceptstruewhen present, andcanceled=Falseremains a PydanticValidationError. Response-sidecanceled: bool | None = Falsestatus indicators are out of scope — their defaults are already non-destructive.What's in the diff
scripts/post_generate_fixes.py_CANCELED_FIELD_REregex +fix_canceled_literal_defaults()wired intomain(). Covers 3 target files (4 total emissions). Idempotent: `Literal[True]src/adcp/types/generated_poc/media_buy/update_media_buy_request.pyUpdateMediaBuyRequest.canceled:Literal[True] = True→ `Literal[True]src/adcp/types/generated_poc/media_buy/package_update.pyPackageUpdate.canceled: same changesrc/adcp/types/generated_poc/bundled/media_buy/update_media_buy_request.pytests/test_canceled_literal_default.pyTrueaccepted, wire payload absent/present,Falserejected, regex idempotencyWhat was tested
pytest tests/ -q: 4316 passed, 30 skipped (1 pre-existing network failuretest_real_tls_handshake_still_validates_hostnamealso fails on main)mypy src/adcp/types/generated_poc/media_buy/update_media_buy_request.py src/adcp/types/generated_poc/media_buy/package_update.py: Success, no issuesruff check src/: All checks passedNits (not fixed — out of PR scope)
inject_literal_discriminator_defaults()already skipsbool-valuedLiteral[True](hasif not isinstance(value, str): continue), so ordering against it is not load-bearing_CANCELED_FIELD_REhardcodes 4-space indentation — consistent with every other fix in this script; idempotency test catches silent no-ops"Set to true to cancel; omit or None to leave unchanged") — considered a follow-upPre-PR review
Literal[True] | None = Nonecorrect;if req.canceled:still falsy-safe for None; no migration doc needed; unusedimport renit fixed before PRSession: https://claude.ai/code/cse_013iJiiNZi9aBGFawGKUNiGw
Generated by Claude Code