multica-ai/multica · error

read tar: %w

Error message

read tar: %w

What it means

tar.Next failed with a non-EOF error while scanning the tar stream; wrapped as 'read tar: %w'. Since the gzip header parsed and the SHA-256 matched the manifest, this indicates structurally invalid tar data (bad header checksum, unsupported typeflag, truncation inside a supposedly verified body).

Source

Thrown at server/internal/cli/update.go:497

}

// extractBinaryFromTarGz reads a .tar.gz stream and returns the contents of the
// named file entry.
func extractBinaryFromTarGz(r io.Reader, name string) ([]byte, error) {
	gz, err := gzip.NewReader(r)
	if err != nil {
		return nil, fmt.Errorf("gzip reader: %w", err)
	}
	defer gz.Close()

	tr := tar.NewReader(gz)
	for {
		hdr, err := tr.Next()
		if err == io.EOF {
			return nil, fmt.Errorf("binary %q not found in archive", name)
		}
		if err != nil {
			return nil, fmt.Errorf("read tar: %w", err)
		}
		// Match the binary name (may be prefixed with a directory).
		if filepath.Base(hdr.Name) == name && hdr.Typeflag == tar.TypeReg {
			data, err := io.ReadAll(tr)
			if err != nil {
				return nil, fmt.Errorf("read binary: %w", err)
			}
			return data, nil
		}
	}
}

// extractBinaryFromZip reads a .zip stream and returns the contents of the
// named file entry. The zip format requires random access, so the full archive
// is buffered in memory.
func extractBinaryFromZip(r io.Reader, name string) ([]byte, error) {
	buf, err := io.ReadAll(r)
	if err != nil {

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Verify the archive opens with system tar (`tar -tzf asset.tar.gz`) to distinguish Go-rejected formats from real corruption.
  2. Rebuild the archive with a standard tool (GNU tar, GoReleaser defaults).
  3. If the asset was truncated at upload, re-run the release upload so checksums.txt matches the complete file.
  4. Report the wrapped error text — tar names the precise header problem.

Example fix

null
Defensive patterns

Strategy: validation

Try / catch

data, err := extractBinaryFromTarGz(r, "multica")
if err != nil && strings.HasPrefix(err.Error(), "read tar") {
    // structurally invalid tar (verified checksum): rebuild archive with standard tooling
}

Prevention

When it happens

Trigger: A tar built with extensions/pax features or a format variant Go's archive/tar rejects; truncation that still matched the manifest because the manifest was computed over the truncated file; hand-crafted archives with incorrect headers.

Common situations: Custom packaging scripts producing non-ustar/GNU headers; a release asset truncated at upload time so checksums.txt describes the truncated bytes; mixing tar implementations across build machines.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/40fb8c3a6a23e2a0. Report an issue: GitHub.