Skip to content
This repository was archived by the owner on Jun 13, 2026. It is now read-only.
This repository was archived by the owner on Jun 13, 2026. It is now read-only.

fix: idempotency-replay DB-row fallback omits context echo on CreateMediaBuySuccess #710

Description

@bokelley

Observed

_build_idempotency_hit_result in src/core/tools/media_buy_create.py has two replay paths:

  • Cached path (~line 2261): reconstructs CreateMediaBuySuccess from the persisted workflow response_data. For buys created after the b9 follow-up: complete adcp b9 behavioral obligations + deferred decisions (from #705 review) #706 work, that dict already carries context/sandbox/account, so they are correctly carried forward. ✅
  • DB-row fallback (~line 2278, hit when there is no cached workflow response_data — e.g. TOCTOU race recovery or a missing workflow step): rebuilds CreateMediaBuySuccess from the ORM row and does not set context, sandbox, or account. The context parameter threaded into the function (line 2230) is unused on this branch.

Expected

Per BR-RULE-043-01, context should be echoed on all success response paths, including the replay fallback.

Why it wasn't fixed in #706

The fallback can't safely echo the current replay request's context — that would break the L1/security idempotency byte-stability rule (replay must match the original response, only envelope fields may differ), which is exactly why #706 deliberately left the replay site without the **_success_extras splat. And it has no access to the original context: it isn't persisted on the media-buy row. A correct fix requires persisting/rehydrating the original context onto the media buy so the fallback can echo the original (not the replay request's) value.

Affected area

  • src/core/tools/media_buy_create.py_build_idempotency_hit_result DB-row fallback branch (~2278) and the unused context parameter.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions