thanos-io/thanos · error

invalid A, AAAA or CNAME response record

Error message

invalid A, AAAA or CNAME response record %s

What it means

lookupIPAddr only knows how to interpret A, AAAA and CNAME answer records. If the DNS response contains any other record type in its answer section (e.g. TXT, PTR, NS), the resolver treats it as a protocol violation and fails with this error instead of silently dropping the record.

Solutions

  1. Check the zone: ensure the queried name's answer section contains only A/AAAA/CNAME records (use dig <name> A to inspect)
  2. Point dns qtype discovery at a dedicated A-record hostname rather than a name with mixed record types
  3. If the extra records are legitimate, switch to a resolver that filters instead of erroring (e.g. net.DefaultResolver)
  4. Fix or remove the offending record type in the DNS zone
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check with a plain DNS query that the name has only A/AAAA/CNAME answers
rr, _ := net.LookupIP(name)
if len(rr) == 0 { /* name unlikely to yield A/AAAA; check zone */ }

Try / catch

ips, err := r.LookupIPAddr(ctx, host)
if err != nil {
    if strings.HasPrefix(err.Error(), "invalid A, AAAA or CNAME response record") {
        // fall back to net.DefaultResolver which ignores unknown record types
    }
    return err
}

Prevention

When it happens

Trigger: Calling LookupIPAddr / dns.Resolve with qtype dns against a name whose DNS answer section contains record types other than A, AAAA, or CNAME — for example querying a name that also carries TXT records, or a server returning unexpected records.

Common situations: Pointing the dns qtype at a hostname that has mixed records; unusual/buggy DNS servers injecting extra record types into answers; operator mistakes where an SRV-style or TXT-heavy name is configured for A/AAAA discovery.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/ad985fa266350a9f. Report an issue: GitHub.

Appendix: source

Thrown at pkg/discovery/dns/miekgdns/resolver.go:152

		}
	}

	var resp []net.IPAddr
	for _, record := range response.Answer {
		switch addr := record.(type) {
		case *dns.A:
			resp = append(resp, net.IPAddr{IP: addr.A})
		case *dns.AAAA:
			resp = append(resp, net.IPAddr{IP: addr.AAAA})
		case *dns.CNAME:
			// Recursively resolve it.
			addrs, err := r.lookupIPAddr(addr.Target, currIteration+1, maxIterations)
			if err != nil {
				return nil, errors.Wrapf(err, "recursively resolve %s", addr.Target)
			}
			resp = append(resp, addrs...)
		default:
			return nil, errors.Errorf("invalid A, AAAA or CNAME response record %s", record)
		}
	}
	return resp, nil
}

func (r *Resolver) IsNotFound(err error) bool {
	return errors.Is(errors.Cause(err), ErrNoSuchHost)
}

View on GitHub (pinned to 35b8b99117)