tailscale/tailscale · warning

unexpectedly large %q file: %d bytes

Error message

unexpectedly large %q file: %d bytes

What it means

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.

Source

Thrown at net/dns/resolvconffile/resolvconffile.go:117

				fqdn, err := dnsname.ToFQDN(domain)
				if err != nil {
					return nil, fmt.Errorf("parsing search domain %q in %q: %w", domain, line, err)
				}
				config.SearchDomains = append(config.SearchDomains, fqdn)
			}
		}
	}
	return config, nil
}

// ParseFile parses the named resolv.conf file.
func ParseFile(name string) (*Config, error) {
	fi, err := os.Stat(name)
	if err != nil {
		return nil, err
	}
	if n := fi.Size(); n > 10<<10 {
		return nil, fmt.Errorf("unexpectedly large %q file: %d bytes", name, n)
	}
	all, err := os.ReadFile(name)
	if err != nil {
		return nil, err
	}
	return Parse(bytes.NewReader(all))
}

View on GitHub (pinned to 6e0912f979)

Solutions

  1. Inspect the file: `ls -l <file>` and `head -50 <file>` to see what filled it.
  2. Trim it back to real directives (keep nameserver/search/options lines) so it is well under 10 KiB.
  3. Fix the generator that appends without bounds — this error is usually a symptom of an unbounded writer.
  4. If the target file legitimately lives elsewhere, pass the correct path to ParseFile.
Defensive patterns

Strategy: validation

Validate before calling

// Mirror the library's guard before calling ParseFile
fi, err := os.Stat(name)
if err != nil {
    return err
}
if fi.Size() > 10<<10 {
    return fmt.Errorf("refusing to parse %s: %d bytes exceeds 10 KiB sanity limit", name, fi.Size())
}

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of tailscale/tailscale@6e0912f979 (2026-08-18). Data as JSON: /api/errors/f432371496668f6b. Report an issue: GitHub.