Skip to content

Commit 78c0e64

Browse files
committed
fix(v3-ref-seller): apply package patches + filter list_creatives
update_media_buy now applies the buyer's package echo fields (targeting_overlay, measurement_terms, etc.) to the shadow store using replacement semantics, so inventory_list_targeting's swap step reads back the new list_id values. list_creatives now honors the request's filters.creative_ids — without the filter the storyboard's creatives[0] lookup picks up a different scenario's creative.
1 parent 517d791 commit 78c0e64

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

examples/v3_reference_seller/src/platform.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,12 @@ async def update_media_buy(
11031103
pkg_state["canceled"] = True
11041104
if getattr(pkg_patch, "paused", None) is not None:
11051105
pkg_state["paused"] = bool(pkg_patch.paused)
1106+
# Echo-field patches use replacement semantics per the wire
1107+
# spec on UpdateMediaBuyRequest.Package — when the buyer
1108+
# supplies a field, it replaces the persisted value; when the
1109+
# field is absent, the previous value survives.
1110+
patch_echo = _project_request_package_echo(pkg_patch)
1111+
pkg_state.update(patch_echo)
11061112
# Attach buyer-assigned creatives upstream so the mock surfaces
11071113
# the assignment on subsequent ``GET .../lineitems`` reads.
11081114
new_assignments = list(getattr(pkg_patch, "creative_assignments", None) or [])
@@ -1566,6 +1572,16 @@ async def list_creatives(
15661572
upstream_creatives = [
15671573
c for c in payload.get("creatives", []) if c.get("advertiser_id") == advertiser_id
15681574
]
1575+
# Apply the buyer-supplied filter on creative_ids. The wire schema
1576+
# accepts buyer-facing ids; translate each through the buyer↔upstream
1577+
# map before matching upstream rows.
1578+
filters = getattr(req, "filters", None)
1579+
wanted_ids = list(getattr(filters, "creative_ids", None) or []) if filters else []
1580+
if wanted_ids:
1581+
upstream_wanted = {self._creative_id_map.get(cid, cid) for cid in wanted_ids}
1582+
upstream_creatives = [
1583+
c for c in upstream_creatives if c.get("creative_id") in upstream_wanted
1584+
]
15691585
total = len(upstream_creatives)
15701586
page = upstream_creatives[offset : offset + limit]
15711587
creatives = [

0 commit comments

Comments
 (0)