{"record":{"id":"2740967be244c45b","repo":"AdguardTeam/AdGuardHome","slug":"parsing-etc-resolv-conf-file-w","errorCode":null,"errorMessage":"parsing etc/resolv.conf file: %w","messagePattern":"parsing etc/resolv\\.conf file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghnet/net_darwin.go","lineNumber":212,"sourceCode":"\tconst filename = \"etc/resolv.conf\"\n\n\t_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {\n\t\tsc := bufio.NewScanner(r)\n\t\tfor sc.Scan() {\n\t\t\tmatches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)\n\t\t\tif len(matches) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor _, m := range matches {\n\t\t\t\taddrs = append(addrs, m[1])\n\t\t\t}\n\t\t}\n\n\t\treturn nil, false, sc.Err()\n\t}).Walk(rootDirFS, filename)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing etc/resolv.conf file: %w\", err)\n\t} else if len(addrs) == 0 {\n\t\treturn nil, fmt.Errorf(\"found no dns servers in %s\", filename)\n\t}\n\n\treturn addrs, nil\n}\n","sourceCodeStart":194,"sourceCodeEnd":219,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghnet/net_darwin.go#L194-L219","documentation":"searchFiles (via setQLogReader) opens a reader over the current and rotated query-log files. If newQLogReader cannot open or parse any of them, the error is wrapped as 'opening qlog reader' and the search fails. This occurs while servicing a query-log search request.","triggerScenarios":"Performing a query-log search when the log files are unreadable (permissions), corrupted (not valid line-delimited JSON), or in a newer format the reader cannot parse after a downgrade.","commonSituations":"Downgrading to an older version that can't read a newer query-log format; partially written/corrupted log after a crash; file permissions changed after restart; empty-but-locked files on Windows.","solutions":["Check the wrapped error for the offending file and OS/parse cause","Repair or delete corrupted rotated log files so the reader can proceed","Align versions (don't downgrade below the log format version) or archive old logs elsewhere","Fix read permissions on the log files and directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check readability of log files\nfor _, f := range files {\n    if fi, err := os.Stat(f); err == nil && fi.Mode().IsRegular() {\n        if fh, err := os.Open(f); err != nil { return err } else { fh.Close() }\n    }\n}","typeGuard":null,"tryCatchPattern":"results, err := qlog.Search(ctx, params)\nif err != nil && strings.Contains(err.Error(), \"qlog reader\") {\n    // degrade gracefully: report search unavailable, keep other API working\n}","preventionTips":["Don't downgrade below the query-log format version","Archive/delete corrupted rotated files","Alert on search endpoint failures to catch corruption early"],"tags":["querylog","search","file-io","go"],"backgroundTag":"file-read-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}