Skip to content

fix: keep Cloudflare record comment and tags when updating the IP - #324

Merged
TimothyYe merged 1 commit into
TimothyYe:masterfrom
MaxFreedomPollard:fix/cloudflare-keep-comment
Oct 23, 2026
Merged

TimothyYe merged 1 commit into
TimothyYe:masterfrom
MaxFreedomPollard:fix/cloudflare-keep-comment

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

Fixes #323.

Bug

When the IP changes, the Cloudflare provider updates the record with PUT /zones/{zone_id}/dns_records/{dns_record_id}. Cloudflare documents that call as Overwrite DNS Record: the request body replaces the whole record. GoDNS only sends id, content, name, proxied, type, zone_id and ttl, so every IP update removed the comment and tags set on the record in the dashboard. #323 reports the lost comment.

Cloudflare's Manage DNS records page says to use PATCH to update part of a record, and PUT only to overwrite the entire record.

Fix

updateRecord now sends the same body with PATCH on the same path (Update DNS Record), which only changes the fields in the body. In Cloudflare's OpenAPI schema, PUT and PATCH accept the same record fields and need the same token permission (DNS Write), so existing configs and tokens keep working.

A comment set in the dashboard now survives IP updates. Setting the comment from the GoDNS config, which #323 also suggests, would be a separate feature and is not part of this change.

Tests

  • The mock in cloudflare_verify_test.go now counts PATCH as the update call. With PUT, TestDedupMultipleStaleRecords and TestRootDomainDedup would fail.
  • New TestUpdateUsesPatch tests the Cloudflare: update will delete comment #323 case.

I could not compile or run the Go tests locally because there is no Go toolchain in my environment, so CI will be the first real run. Instead, I checked the change against a Python re-implementation of the provider and of this mock. With PUT, the three tests above fail. With PATCH, all six tests in the file pass.

🤖 Generated with Claude Code

updateRecord sent the record with PUT, which Cloudflare documents as
"Overwrite DNS Record": the record is replaced by the request body, so
every IP update wiped the comment and tags set on the record (TimothyYe#323).
Send the same body with PATCH ("Update DNS Record"), which only changes
the fields that are sent.

The verify test mock now records PATCH as the update call, and
TestUpdateUsesPatch covers the issue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TimothyYe
TimothyYe merged commit 88b5c00 into TimothyYe:master Oct 23, 2026
3 checks passed
@TimothyYe

Copy link
Copy Markdown
Owner

Thanks a lot!

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.

Cloudflare: update will delete comment

2 participants