{"record":{"id":"f432371496668f6b","repo":"tailscale/tailscale","slug":"unexpectedly-large-q-file-d-bytes","errorCode":null,"errorMessage":"unexpectedly large %q file: %d bytes","messagePattern":"unexpectedly large %q file: (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"net/dns/resolvconffile/resolvconffile.go","lineNumber":117,"sourceCode":"\t\t\t\tfqdn, err := dnsname.ToFQDN(domain)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"parsing search domain %q in %q: %w\", domain, line, err)\n\t\t\t\t}\n\t\t\t\tconfig.SearchDomains = append(config.SearchDomains, fqdn)\n\t\t\t}\n\t\t}\n\t}\n\treturn config, nil\n}\n\n// ParseFile parses the named resolv.conf file.\nfunc ParseFile(name string) (*Config, error) {\n\tfi, err := os.Stat(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif n := fi.Size(); n > 10<<10 {\n\t\treturn nil, fmt.Errorf(\"unexpectedly large %q file: %d bytes\", name, n)\n\t}\n\tall, err := os.ReadFile(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn Parse(bytes.NewReader(all))\n}\n","sourceCodeStart":99,"sourceCodeEnd":125,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/net/dns/resolvconffile/resolvconffile.go#L99-L125","documentation":"resolvconffile.ParseFile stats the file before reading and refuses anything over 10 KiB (10<<10 bytes) — a sanity cap so a corrupted or adversarially large 'resolv.conf' cannot be fully read and scanned. The error names the file and its size. Real resolv.conf files are a few hundred bytes at most.","triggerScenarios":"ParseFile(name) where os.Stat reports a size greater than 10240 bytes — e.g. a resolv.conf that grew from repeated appended comments, a wrong file (log or core dump symlinked as resolv.conf), or a generated file stuck in a write loop.","commonSituations":"Scripts appending comments/backup lines on every invocation until the file balloons; a bind-mount or symlink mistake pointing ParseFile at a large unrelated file; containers with badly templated resolv.conf.","solutions":["Inspect the file: `ls -l <file>` and `head -50 <file>` to see what filled it.","Trim it back to real directives (keep nameserver/search/options lines) so it is well under 10 KiB.","Fix the generator that appends without bounds — this error is usually a symptom of an unbounded writer.","If the target file legitimately lives elsewhere, pass the correct path to ParseFile."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Mirror the library's guard before calling ParseFile\nfi, err := os.Stat(name)\nif err != nil {\n    return err\n}\nif fi.Size() > 10<<10 {\n    return fmt.Errorf(\"refusing to parse %s: %d bytes exceeds 10 KiB sanity limit\", name, fi.Size())\n}","typeGuard":null,"tryCatchPattern":"Catch the error, show the operator the file size, and require manual inspection of the oversized file — automatically truncating a config file in a catch block risks destroying the real (garbage-accumulated) content.","preventionTips":["Bound resolv.conf growth at the source: no unbounded comment appends.","Alert on resolv.conf size exceeding ~1 KiB as an early warning.","Check for symlink/bind-mount mistakes when the path should be a small config."],"tags":["linux","dns","resolv-conf","file-size"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}