rdev/internal/domain/dns.go
jordan ee1c214b7e
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
fix: correct Resend DNS record type, name, and MX priority
Three bugs in the notify provisioner DNS record upsert:

1. rec.Record ("DKIM"/"SPF") was used as the DNS record type — Cloudflare
   doesn't know those labels. Fix: use rec.DNSType ("TXT"/"MX") from the
   resendDNSRecord.type JSON field, which is the actual DNS record type.

2. rec.Name from Resend is already relative to the zone apex
   (e.g., "resend._domainkey.mail.project-name"), not relative to the
   registered domain. Code was doing rec.Name + "." + host which produced
   a doubled subdomain. Fix: pass rec.Name directly — Cloudflare's
   normalizeName appends ".baseDomain" to build the correct FQDN.

3. MX records have priority 10 in Resend's response but DNSRecord had no
   Priority field and Cloudflare CreateRecord/UpdateRecord didn't send it.
   Fix: add Priority int to domain.DNSRecord and include it in the body
   for both Create and Update when non-zero.

These bugs caused DKIM/SPF DNS records to never be created for any project.
Re-provision affected projects using POST /projects/{id}/notify/provision
after clearing NOTIFY_RESEND_DOMAIN_ID from the credential store.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 19:52:11 -07:00

23 lines
693 B
Go

// Package domain contains pure domain models with no external dependencies.
package domain
// DNSRecord represents a DNS record in a zone.
type DNSRecord struct {
ID string // Provider-specific ID
Type string // A, AAAA, CNAME, TXT, MX, etc.
Name string // Subdomain or @ for root
Content string // IP address or target
TTL int // TTL in seconds, 1 = auto
Proxied bool // Cloudflare proxy enabled
Priority int // MX/SRV record priority (0 = not set)
}
// DNSRecordType constants for common record types.
const (
DNSRecordTypeA = "A"
DNSRecordTypeAAAA = "AAAA"
DNSRecordTypeCNAME = "CNAME"
DNSRecordTypeTXT = "TXT"
DNSRecordTypeMX = "MX"
)