fix(training-agent): reject creative_assignments: [] on active/paused buys#3286
Draft
fix(training-agent): reject creative_assignments: [] on active/paused buys#3286
Conversation
… buys update_media_buy with an empty creative_assignments array on a live buy caused deriveStatus to return pending_creatives (hasCreatives === false), emitting an active → pending_creatives transition not in MEDIA_BUY_TRANSITIONS. Guard added in the pre-validation pass: if the buy is in active, paused, or pending_start status, clearing all assignments on any package returns VALIDATION_ERROR before any mutation occurs. Updated the comment at the mutation site to reflect that the empty-array case is now pre-empted. Closes #2835 https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
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 #2835
update_media_buywithcreative_assignments: []on a package of an active buy causedderiveStatusto returnpending_creatives(becausehasCreatives === false), emitting anactive → pending_creativestransition that is not inMEDIA_BUY_TRANSITIONS. Thestatus.monotonicinvariant assertion would reject this transition the moment any storyboard exercises the "buyer replaces all creatives" path.Fix: Validation guard added in the pre-validation pass (
handleUpdateMediaBuy, pre-pass loop). If the buy's derived status isactive,paused, orpending_start, clearing all assignments on any package returnsVALIDATION_ERRORbefore any mutation occurs. This is Option 2 from the issue — cleaner than thecreaturesWereAttachedbit (Option 1) because it keepsderiveStatusandMEDIA_BUY_TRANSITIONSuntouched and produces a clear API error the agent under test can observe.Non-breaking justification: Server-only change in
task-handlers.ts; no protocol schema, task definition, or published API surface touched. Changeset--empty.Pre-PR review:
Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Generated by Claude Code