fix(google-tag-manager): keep untouched fields on update, add create_version

YU
13d ago
+183-23

Problem

The GTM API's PUT replaces the whole entity. update_tag, update_trigger and update_variable forwarded only a few fields, so every update silently deleted the rest. Lost fields included:

  • consentSettings, which holds the Consent Mode/LGPD check of tags that need consent;
  • parentFolderId;
  • setupTag/teardownTag;
  • priority and the schedule.

get_tag also hid consentSettings, so callers could not notice.

Found while preparing the Grupo Dass containers (GTM-TL4DML26, GTM-P8Q5HMS, GTM-M6QJTLF). Tags lost their folder on update, and tags that need consent could not be edited safely.

Fix

  • GTMClient.mergedPut: reads the current entity, overlays only the fields the caller set (undefined is skipped), then sends the PUT. Used by all three update methods.
  • Tag tools: get/list/update return consentSettings. update_tag accepts consentSettings and parentFolderId.
  • Variable formatValue: typed as the options object GTM returns. The old Parameter schema made list_variables/get_variable fail output validation.
  • New create_version tool: workspaces/{id}:create_version. It never publishes.

Validation

  • bun test: new gtm-client.test.ts checks that an update keeps consentSettings, parentFolderId and setupTag, and drops undefined keys.
  • bun run check: no new errors. The existing @decocms/bindings EventBusBindingClient error also happens on main.

🤖 Generated with Claude Code


Summary by cubic

Fixes GTM tag, trigger, and variable updates silently deleting fields the tool didn't forward. The GTM API's PUT replaces the whole entity, so every update dropped the consent settings, folder, setup/teardown tags, priority, and schedule.

  • Update methods now merge the caller's input over the current entity, keeping untouched fields.
  • Tag get/list/update expose consentSettings; update_tag accepts consentSettings and parentFolderId.
  • Variable formatValue is now the options object GTM returns, fixing list_variables/get_variable output validation.
  • Added a create_version tool that creates a container version without publishing.