{"record":{"id":"d6fc2405dea3aac3","repo":"coredns/coredns","slug":"failed-to-parse-q-v","errorCode":null,"errorMessage":"failed to parse %q: %v","messagePattern":"failed to parse %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/autopath/setup.go","lineNumber":60,"sourceCode":"}\n\nfunc autoPathParse(c *caddy.Controller) (*AutoPath, string, error) {\n\tap := &AutoPath{}\n\tmw := \"\"\n\n\tfor c.Next() {\n\t\tzoneAndresolv := c.RemainingArgs()\n\t\tif len(zoneAndresolv) < 1 {\n\t\t\treturn ap, \"\", fmt.Errorf(\"no resolv-conf specified\")\n\t\t}\n\t\tresolv := zoneAndresolv[len(zoneAndresolv)-1]\n\t\tif strings.HasPrefix(resolv, \"@\") {\n\t\t\tmw = resolv[1:]\n\t\t} else {\n\t\t\t// assume file on disk\n\t\t\trc, err := dns.ClientConfigFromFile(resolv)\n\t\t\tif err != nil {\n\t\t\t\treturn ap, \"\", fmt.Errorf(\"failed to parse %q: %v\", resolv, err)\n\t\t\t}\n\t\t\tap.search = rc.Search\n\t\t\tplugin.Zones(ap.search).Normalize()\n\t\t\tap.search = append(ap.search, \"\") // sentinel value as demanded.\n\t\t}\n\t\tzones := zoneAndresolv[:len(zoneAndresolv)-1]\n\t\tap.Zones = plugin.OriginsFromArgsOrServerBlock(zones, c.ServerBlockKeys)\n\t}\n\treturn ap, mw, nil\n}\n","sourceCodeStart":42,"sourceCodeEnd":71,"githubUrl":"https://github.com/coredns/coredns/blob/558c9757a92b361e550bdba82d0b4ddf3d12d595/plugin/autopath/setup.go#L42-L71","documentation":"When the autopath resolv-conf argument is not an @middleware reference, it is treated as a path to a resolv.conf file parsed with dns.ClientConfigFromFile. If that file cannot be read or parsed, the error wraps the underlying cause. This is typically a missing file or malformed resolv.conf.","triggerScenarios":"autoPathParse calls dns.ClientConfigFromFile(resolv) and it returns an error — file does not exist, unreadable permissions, or invalid resolv.conf syntax.","commonSituations":"Typo in the resolv.conf path in the Corefile; running in a container where /etc/resolv.conf is absent; malformed resolv.conf (bad nameserver line).","solutions":["Verify the path in `autopath <path>` points to an existing, readable resolv.conf file","Fix syntax errors in the resolv.conf file (check the wrapped %v cause)","Use `@kubernetes` style middleware reference instead of a file path if appropriate"],"exampleFix":"# before\nautopath /etc/resolve.conf\n# after\nautopath /etc/resolv.conf","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(resolvPath); err != nil { return fmt.Errorf(\"resolv.conf not readable: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := runCoreDNS(); err != nil { if strings.Contains(err.Error(), \"failed to parse\") { log.Fatalf(\"check autopath resolv.conf path/syntax: %v\", err) } }","preventionTips":["Stat/open the resolv.conf path before referencing it in the Corefile","In containers, ensure /etc/resolv.conf is mounted","Prefer @middleware references when a plugin provides the search path"],"tags":["coredns","autopath","resolv-conf","file-parse"],"backgroundTag":"file-not-found","analyzedSha":"558c9757a92b361e550bdba82d0b4ddf3d12d595","analyzedAt":"2026-09-06T22:47:02.106Z","contentChangedAt":"2026-09-06T22:47:02.106Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}