golang/go · critical · base.Fatalf

verifying %v

Error message

verifying %v

What it means

Reached during verification of a module's zip hash (the `-mod=mod` download / go mod verify path). The block calls base.Fatalf — which terminates the process — when hashZip fails or when the recorded ziphash lacks the required 'h1:' algorithm prefix. This is a fatal exit, not a returned error.

Source

Thrown at src/cmd/go/internal/modfetch/fetch.go:728

	if err != nil {
		base.Fatalf("verifying %v", module.VersionError(mod, err))
	}
	data = bytes.TrimSpace(data)
	if !isValidSum(data) {
		// Recreate ziphash file from zip file and use that to check the mod sum.
		zip, err := CachePath(ctx, mod, "zip")
		if err != nil {
			base.Fatalf("verifying %v", module.VersionError(mod, err))
		}
		err = hashZip(f, mod, zip, ziphash)
		if err != nil {
			base.Fatalf("verifying %v", module.VersionError(mod, err))
		}
		return
	}
	h := string(data)
	if !strings.HasPrefix(h, "h1:") {
		base.Fatalf("verifying %v", module.VersionError(mod, fmt.Errorf("unexpected ziphash: %q", h)))
	}

	if err := checkModSum(f, mod, h); err != nil {
		base.Fatalf("%s", err)
	}
}

// goModSum returns the checksum for the go.mod contents.
func goModSum(data []byte) (string, error) {
	return dirhash.Hash1([]string{"go.mod"}, func(string) (io.ReadCloser, error) {
		return io.NopCloser(bytes.NewReader(data)), nil
	})
}

// checkGoMod checks the given module's go.mod checksum;
// data is the go.mod content.
func checkGoMod(f *Fetcher, path, version string, data []byte) error {
	h, err := goModSum(data)

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Run go clean -modcache and re-download the offending module.
  2. Check the filesystem for the cache directory: full disk, permission errors, or bit-rot.
  3. Ensure only one Go toolchain version writes to the shared GOMODCACHE.
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking any command that triggers verification, sanity-check the
// ziphash file format.
func ziphashLooksValid(p string) error {
    b, err := os.ReadFile(p)
    if err != nil { return err }
    if !strings.HasPrefix(string(b), "h1:") {
        return fmt.Errorf("ziphash %s missing h1: prefix", p)
    }
    return nil
}

Try / catch

// base.Fatalf exits the process; there is no catch. Validate inputs first and
// run verification in a sandboxed subprocess so an abort does not take down
// the parent.
out, err := exec.Command("go", "mod", "verify").CombinedOutput()
if err != nil { /* handle fatal verification abort */ }

Prevention

When it happens

Trigger: CachePath for the zip fails, hashZip returns an error computing the directory hash, or the stored ziphash file content does not start with 'h1:'. base.Fatalf prints the message and os.Exit(2).

Common situations: Corrupted or truncated ziphash file in GOMODCACHE; partial download left a half-written hash; disk error during hashing; cache populated by an incompatible go version.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/c73c90e2339f2c6c. Report an issue: GitHub.