Skip to content

CLOUDFLAREAPI: Fix comment and tag removal not taking effect#4045

Merged
tlimoncelli merged 1 commit intoStackExchange:mainfrom
allixsenos:fix/cf-comment-tag-removal
Feb 2, 2026
Merged

CLOUDFLAREAPI: Fix comment and tag removal not taking effect#4045
tlimoncelli merged 1 commit intoStackExchange:mainfrom
allixsenos:fix/cf-comment-tag-removal

Conversation

@allixsenos
Copy link
Copy Markdown
Contributor

Summary

  • Fixes comment and tag removal not actually clearing values via the Cloudflare API, causing preview/push to show the same correction on every run without converging
  • preprocessConfig now ensures metadata keys exist (set to "") on every desired record when CF_MANAGE_COMMENTS or CF_MANAGE_TAGS is enabled, so modifyRecord correctly sends empty values to the API
  • modifyRecord tags path now sends an empty slice ([]string{}) to clear tags, matching the comment pattern which already sent &"" to clear comments

Fixes #4039

Test plan

  • Unit tests for preprocessConfig metadata key initialization (4 tests)
  • Unit tests for genComparableWithMgmt edge cases (6 subtests)
  • All existing cloudflare provider tests pass
  • Broader test suite passes (commands, models, pkg)
  • Manual test: removing CF_COMMENT from a record clears the comment in Cloudflare
  • Manual test: removing CF_TAGS from a record clears all tags in Cloudflare
  • Manual test: subsequent preview/push shows 0 corrections (convergence verified)

When removing CF_COMMENT or CF_TAGS from a record, dnscontrol detected
the change but the API call didn't actually clear the values. This
caused preview/push to show the same correction on every run.

Root cause: modifyRecord checked for metadata key existence (comments)
or non-empty value (tags) before setting the API fields. When a record
had no comment/tags in the desired config, the metadata key was absent
entirely, so the API fields were omitted — which Cloudflare interprets
as "keep the existing value."

Fix: preprocessConfig now ensures the metadata key exists (set to "")
on every record when management is enabled. modifyRecord's existing
ok-check then correctly sends an empty string to clear comments, and
the tags path now sends an empty slice to clear tags.

Fixes StackExchange#4039
@tlimoncelli
Copy link
Copy Markdown
Contributor

Thanks for the fast fix!

@tlimoncelli tlimoncelli merged commit ec5e9b7 into StackExchange:main Feb 2, 2026
@allixsenos allixsenos deleted the fix/cf-comment-tag-removal branch February 2, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLOUDFLAREAPI: Comment tests failing

3 participants