{"record":{"id":"ad985fa266350a9f","repo":"thanos-io/thanos","slug":"invalid-a-aaaa-or-cname-response-record-s","errorCode":null,"errorMessage":"invalid A, AAAA or CNAME response record %s","messagePattern":"invalid A, AAAA or CNAME response record (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/discovery/dns/miekgdns/resolver.go","lineNumber":152,"sourceCode":"\t\t}\n\t}\n\n\tvar resp []net.IPAddr\n\tfor _, record := range response.Answer {\n\t\tswitch addr := record.(type) {\n\t\tcase *dns.A:\n\t\t\tresp = append(resp, net.IPAddr{IP: addr.A})\n\t\tcase *dns.AAAA:\n\t\t\tresp = append(resp, net.IPAddr{IP: addr.AAAA})\n\t\tcase *dns.CNAME:\n\t\t\t// Recursively resolve it.\n\t\t\taddrs, err := r.lookupIPAddr(addr.Target, currIteration+1, maxIterations)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"recursively resolve %s\", addr.Target)\n\t\t\t}\n\t\t\tresp = append(resp, addrs...)\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"invalid A, AAAA or CNAME response record %s\", record)\n\t\t}\n\t}\n\treturn resp, nil\n}\n\nfunc (r *Resolver) IsNotFound(err error) bool {\n\treturn errors.Is(errors.Cause(err), ErrNoSuchHost)\n}\n","sourceCodeStart":134,"sourceCodeEnd":161,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/discovery/dns/miekgdns/resolver.go#L134-L161","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the zone: ensure the queried name's answer section contains only A/AAAA/CNAME records (use dig <name> A to inspect)","Point dns qtype discovery at a dedicated A-record hostname rather than a name with mixed record types","If the extra records are legitimate, switch to a resolver that filters instead of erroring (e.g. net.DefaultResolver)","Fix or remove the offending record type in the DNS zone"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check with a plain DNS query that the name has only A/AAAA/CNAME answers\nrr, _ := net.LookupIP(name)\nif len(rr) == 0 { /* name unlikely to yield A/AAAA; check zone */ }","typeGuard":null,"tryCatchPattern":"ips, err := r.LookupIPAddr(ctx, host)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"invalid A, AAAA or CNAME response record\") {\n        // fall back to net.DefaultResolver which ignores unknown record types\n    }\n    return err\n}","preventionTips":["Use dig <name> to confirm the answer section only holds A/AAAA/CNAME","Dedicate A-record-only hostnames for dns qtype discovery","Don't point dns qtype at names carrying TXT/SRV answers in the same owner name","Prefer net.DefaultResolver if zones contain mixed records"],"tags":["dns","unexpected-response","record-type"],"backgroundTag":"unexpected-response-shape","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}