feat(examples): MediaBuy.invoice_recipient first-class column (3.1 readiness)#395
Draft
feat(examples): MediaBuy.invoice_recipient first-class column (3.1 readiness)#395
Conversation
- Fix status_filter single-enum branch: .value not str() (was silently returning zero rows) - Remove generated_poc import: use dict + model_validate on GetMediaBuysResponse instead - Skip rows with NULL currency/total_budget instead of fabricating wire data - Use model_fields_set to allow explicit null clearing of invoice_recipient in update https://claude.ai/code/session_01CixjgSAnrbc2cdHYDrFcfH
5 tasks
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 #378
AdCP 3.1 surfaces
media_buy.invoice_recipientas a per-buy billing entity override. Previously it was buried inrequest_snapshotonly — not queryable, not enforceable, and not surfaced in responses. This PR promotes it to a first-class SQLAlchemy column and wires it through the full create → update → list lifecycle in the v3 reference seller.Changes:
models.py: adds nullableinvoice_recipientJSON column toMediaBuy; updates module docstring to note 3.1-readiness alongsideAccountplatform.py: extracts and persistsinvoice_recipientincreate_media_buy; propagates it (including explicit-null clearing viamodel_fields_set) inupdate_media_buy; addsget_media_buysimplementation that queries the column and strips write-onlybankvia_project_invoice_recipient(); uses dict-basedGetMediaBuysResponse.model_validate()to avoid importinggenerated_pocdirectlytests/test_smoke.py: two new tests — ORM column presence check andBusinessEntityResponsebank-stripping round-tripREADME.md: updates the Spec versioning section to enumerateinvoice_recipientalongside the other 3.1-ready columnsWhat was tested:
pytest examples/v3_reference_seller/tests/test_smoke.py::test_invoice_recipient_round_trips_without_bank— passespytest tests/ -q— 3097 passed, 1 pre-existing failure (TLS integration test unrelated to this change)ruff check examples/v3_reference_seller/src/— all checks passedmypy src/adcp/ --ignore-missing-imports— no issues found in 744 source filesNits (not fixed, surfaced for reviewer):
status_filterduck-typing viahasattr(..., "root")is fragile if generated shape changes; preferisinstance(status_filter, RootModel)with a commenttest_smoke.pytest replicates_project_invoice_recipientlogic inline rather than importing the function directlyPre-PR review:
str(status_filter)→.valueblocker (silent zero-row bug), fixedgenerated_pocimport violation via dict+model_validate, fixedcurrency/total_budgetnull fabrication, fixedmodel_fields_setfor clearable update; 2 nits noted above_project_invoice_recipientfollowsto_account_responsepattern, migration comment in docstring addresses adopter gotcha,generated_pocimport violation resolved via dict approachSession: https://claude.ai/code/session_01CixjgSAnrbc2cdHYDrFcfH
Generated by Claude Code