Skip to content

draft_update_conversion_action: add category, refuse include_in_conversions_metric - #122

Merged
kLOsk merged 2 commits into
kLOsk:mainfrom
illia-sapryga:feat/conversion-action-category
Nov 12, 2026
Merged

kLOsk merged 2 commits into
kLOsk:mainfrom
illia-sapryga:feat/conversion-action-category

Conversation

@illia-sapryga

Copy link
Copy Markdown
Contributor

Two related changes to one tool.

The docstring says include_in_conversions_metric is mutable on update. It isn't. On a real account Google answered IMMUTABLE_FIELD at apply, after the validate-only dry run had passed, so the preview and the dry run both looked fine and only the real apply failed. Google derives the value from primary_for_goal and whether the goal of the action's category is biddable. The draft now refuses the parameter and names those two instead. I kept the parameter so a caller gets that message and not a schema error. A plan already stored with the field raises at apply and sends nothing. The create tool's docs pointed at the update tool for this, so I corrected those too.

That leaves a gap: an action in a category whose goal isn't biddable has no way to start counting through AdLoop. category closes it by moving the action to another goal, for example DEFAULT to PHONE_CALL_LEAD. The preview shows current_category and warns that campaigns bidding on those goals can start or stop optimizing toward it. The same category, a removed action and an unknown ID are refused at draft time.

What it does not do: it doesn't change primary_for_goal, and it doesn't check whether the target goal is biddable, so the warning says "only if". There is no re-check of the category at apply; the tool's other fields have none either. I left the rules file alone because these tools aren't listed there and the refusal message explains itself.

Tested with the full suite. test_include_in_conversions_metric_is_mutable_on_update and test_update_include_in_conversions_metric_fieldmask asserted the old behaviour and are replaced by tests of the refusal. The category path runs through confirm_and_apply(dry_run=True) with real protos, the real validate-only wrapper and a fake service, and GAQL is stubbed. I saw the IMMUTABLE_FIELD answer on a live account, but this code has not been run against one, and validate-only is known not to catch that particular error, so a green dry run says little about real updates to this tool.

@kLOsk

kLOsk commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks, the include_in_conversions_metric fix is right, and category is a good way to close the gap. One thing before merging:

Re-check the category at apply. Moving an action to another goal can start or stop campaigns bidding on it, so please re-read conversion_action.category in _apply_update_conversion_action and refuse, with nothing sent, if it no longer matches current_category. The asset tools do the same since 0.34.0, and it covers the dry run too.

#124 is merged and touches tests/test_conversion_actions.py, so this needs a small rebase.

…rsions_metric

category moves the action to another goal; the preview shows the current one.

include_in_conversions_metric was documented as mutable on update. Google
answers IMMUTABLE_FIELD at the real apply and validate_only does not catch it,
so the draft now refuses it and names primary_for_goal and category instead.
Moving an action to another goal can start or stop campaigns bidding on
it. The preview pins the category it showed (current_category), and the
apply now re-reads conversion_action.category before anything is sent:
if it changed in Google Ads since the preview, or the action is gone,
nothing is sent and the edit has to be drafted again. It is a read, so
the dry run refuses the same way, as the asset edits do. Plans that do
not change the category skip the read.
@illia-sapryga
illia-sapryga force-pushed the feat/conversion-action-category branch from e8bf2ef to ddf803a Compare November 10, 2026 22:01
@illia-sapryga

Copy link
Copy Markdown
Contributor Author

Thanks, Daniel. Rebased onto main (the only conflict was at the end of tests/test_conversion_actions.py; #124's tests are kept) and added ddf803a.

_apply_update_conversion_action now re-reads conversion_action.category before anything is sent. It refuses if the category no longer matches current_category, or if the action is gone, with the same "was changed in Google Ads after this preview; nothing was sent" wording as the asset edits. The read goes through GoogleAdsService.search, so the dry run refuses the same way. Plans that don't move the category skip it.

Tests cover a changed category (dry run and apply, nothing sent), an unchanged one (only category is sent), a removed action, and plans without a category change.

@kLOsk
kLOsk merged commit c5d09df into kLOsk:main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants