Skip to content

Preserve DNS provider metadata for DNS-01 cleanup#382

Merged
mholt merged 1 commit into
caddyserver:masterfrom
bjornmp:preserve-dns-provider-record-data
May 12, 2026
Merged

Preserve DNS provider metadata for DNS-01 cleanup#382
mholt merged 1 commit into
caddyserver:masterfrom
bjornmp:preserve-dns-provider-record-data

Conversation

@bjornmp
Copy link
Copy Markdown
Contributor

@bjornmp bjornmp commented May 9, 2026

Summary

This change stores the full libdns.Record returned by AppendRecords while a DNS-01 challenge is active, instead of reducing it to record.RR() immediately.

The portable DNS fields are still accessed through record.RR() for propagation checks, logging, and memory lookup. Cleanup now passes the original returned record back to DeleteRecords, preserving provider-specific metadata such as ProviderData.

Why

Some libdns providers receive an internal record ID from the provider API when creating a record and store it in ProviderData. If CertMagic discards that metadata, cleanup may need to list zone records and rediscover the provider ID before deletion.

Preserving the returned record is more robust:

  • Providers with record IDs can delete directly without an extra list call.
  • Tokens do not need list permissions solely to rediscover an ID that was already returned during creation.
  • Providers without metadata continue to work because the standard DNS data remains available through Record.RR().

This does not make CertMagic depend on provider-specific IDs. It only avoids discarding metadata when a provider supplies it.

Validation

Added a regression unit test verifying that cleanup receives the original returned record including ProviderData.

Tested with:

go test ./...

Fixes #381

Copy link
Copy Markdown
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, didn't realize ProviderData was that useful, but this makes sense! Thanks.

@mholt mholt merged commit 9f98c96 into caddyserver:master May 12, 2026
6 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.

Preserve DNS provider metadata for DNS-01 cleanup

2 participants