{"record":{"id":"0d49d92339d99dc5","repo":"thanos-io/thanos","slug":"invalid-srv-response-record-s","errorCode":null,"errorMessage":"invalid SRV response record %s","messagePattern":"invalid SRV response record (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/discovery/dns/miekgdns/resolver.go","lineNumber":60,"sourceCode":"\n\tfor _, record := range response.Answer {\n\t\tswitch addr := record.(type) {\n\t\tcase *dns.SRV:\n\t\t\taddrs = append(addrs, &net.SRV{\n\t\t\t\tWeight:   addr.Weight,\n\t\t\t\tTarget:   addr.Target,\n\t\t\t\tPriority: addr.Priority,\n\t\t\t\tPort:     addr.Port,\n\t\t\t})\n\t\tcase *dns.CNAME:\n\t\t\t// Recursively resolve it.\n\t\t\t_, resp, err := r.lookupSRV(\"\", \"\", 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\taddrs = append(addrs, resp...)\n\t\tdefault:\n\t\t\treturn \"\", nil, errors.Errorf(\"invalid SRV response record %s\", record)\n\t\t}\n\t}\n\n\treturn \"\", addrs, nil\n}\n\nfunc (r *Resolver) LookupIPAddr(_ context.Context, host string) ([]net.IPAddr, error) {\n\treturn r.lookupIPAddr(host, 1, 8)\n}\n\nfunc (r *Resolver) LookupIPAddrByNetwork(ctx context.Context, network, host string) ([]net.IPAddr, error) {\n\tvar qtype dns.Type\n\tswitch network {\n\tcase \"ip6\":\n\t\tqtype = dns.Type(dns.TypeAAAA)\n\tcase \"ip4\":\n\t\tqtype = dns.Type(dns.TypeA)\n\tdefault:","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/discovery/dns/miekgdns/resolver.go#L42-L78","documentation":"The SRV answer contained a record type the resolver does not handle: only *dns.SRV and *dns.CNAME are accepted, and anything else (A, TXT, SOA, etc.) aborts the lookup with this error naming the offending record. It indicates the DNS server returned a malformed or unexpected answer for an SRV query.","triggerScenarios":"Iterating msg.Answer of an SRV response and hitting the default case — the server answered with records other than SRV/CNAME, e.g. an A record set for what should be an SRV name.","commonSituations":"Misconfigured DNS server or load balancer answering A records for SRV queries; middleboxes/DPI rewriting DNS answers; wrong record type registered for the _service._proto name.","solutions":["Inspect the record named in the error with dig SRV <name> +noall +answer to see what the server actually returns","Fix the DNS zone: create a proper SRV record at _service._proto.name instead of A/TXT records","If a proxy/firewall alters DNS replies, bypass or fix it","Point the resolver at a DNS server that correctly serves the SRV zone"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the record type actually served\nout, _ := exec.Command(\"dig\", \"+short\", \"SRV\", name).Output()\nif !strings.Contains(string(out), \"SRV\") { /* wrong record type registered */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid SRV response record\") {\n    return fmt.Errorf(\"DNS server misbehaving for %s: %w\", name, err) // don't retry blindly\n}","preventionTips":["Register correct SRV records (_service._proto.name SRV ...) rather than A/TXT at those names","Test with dig SRV before wiring up discovery","Bypass or reconfigure middleboxes that rewrite DNS answers","Use a reputable DNS server for zones serving SRV records"],"tags":["dns","srv","unexpected-response"],"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"}