golang/go · error
ReadZip: encoded file exceeds allowed size
Error message
ReadZip: encoded file exceeds allowed size
What it means
ReadZip funnels the VCS-produced archive (git/hg archive) through a limitedWriter capped at the caller-supplied maxSize, which ultimately derives from codehost.MaxZipFile (500 MiB). If the encoded zip would exceed the cap, the writer short-writes and returns this error, aborting the read.
Source
Thrown at src/cmd/go/internal/modfetch/codehost/vcs.go:628
if err != nil {
return nil, err
}
unlock, err := r.mu.Lock()
if err != nil {
return nil, err
}
defer unlock()
f, err := os.CreateTemp("", "go-readzip-*.zip")
if err != nil {
return nil, err
}
if r.cmd.doReadZip != nil {
lw := &limitedWriter{
W: f,
N: maxSize,
ErrLimitReached: errors.New("ReadZip: encoded file exceeds allowed size"),
}
err = r.cmd.doReadZip(ctx, lw, r.dir, rev, subdir, r.remote)
if err == nil {
_, err = f.Seek(0, io.SeekStart)
}
} else if r.cmd.vcs == "fossil" {
// If you run
// fossil zip -R .fossil --name prefix trunk /tmp/x.zip
// fossil fails with "unable to create directory /tmp" [sic].
// Change the command to run in /tmp instead,
// replacing the -R argument with an absolute path.
args := r.cmd.readZip(rev, subdir, r.remote, filepath.Base(f.Name()))
for i := range args {
if args[i] == ".fossil" {
args[i] = filepath.Join(r.dir, ".fossil")
}
}
_, err = Run(ctx, filepath.Dir(f.Name()), args)View on GitHub (pinned to b6b368adc5)
Solutions
- Narrow the module: pick a subdir, split the module, or remove large generated/binary files from the repository.
- Pin to a smaller revision or tag that predates the bulk that pushed it over the limit.
- If you control the toolchain, raise codehost.MaxZipFile and rebuild go; otherwise request the upstream maintainer trim the repo.
Defensive patterns
Strategy: fallback
Prevention
- Keep modules small; split monorepos into multiple modules by subtree.
- Avoid checking large generated artifacts or binaries into a module's repo.
When it happens
Trigger: A module's zip representation produced by the VCS for the requested revision/subdir exceeds the maxSize limit passed to ReadZip.
Common situations: Very large repositories fetched as a module; requesting a wide revision range or no subdir so the whole repo is archived; vendored large binaries or generated files inside the repo; a heavy subdirectory selected as subdir.
Related errors
- https fetch: %v
- parsing %s: %v
- parse %s: %v
- parse %s: no go-import meta tags (%s)
- %s and %s disagree about go-import for %s
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/0c33e9012264c6d8.
Report an issue: GitHub.