vxcontrol/pentagi · error
tar entry '%s' has invalid size %d
Error message
tar entry '%s' has invalid size %d
What it means
For regular-file entries, ExtractTar validates hdr.Size before accounting. A negative size is impossible for well-formed archives produced by archive/tar, so this error indicates a malformed or hostile header. It is a defensive integrity check, not an environmental failure.
Source
Thrown at backend/pkg/flowfiles/files.go:403
return fmt.Errorf("failed to read tar entry: %w", err)
}
if hdr.Typeflag == tar.TypeSymlink || hdr.Typeflag == tar.TypeLink {
continue
}
entryPath := filepath.Join(destDir, filepath.Clean(filepath.FromSlash(hdr.Name)))
if !IsWithinDir(entryPath, destDir) {
continue
}
switch hdr.Typeflag {
case tar.TypeDir:
if err := os.MkdirAll(entryPath, 0755); err != nil {
return fmt.Errorf("failed to create directory '%s': %w", entryPath, err)
}
case tar.TypeReg, tar.TypeRegA:
if hdr.Size < 0 {
return fmt.Errorf("tar entry '%s' has invalid size %d", hdr.Name, hdr.Size)
}
filesCount++
if filesCount > MaxPullFiles {
return fmt.Errorf("tar archive exceeds maximum file count of %d", MaxPullFiles)
}
totalSize += hdr.Size
if totalSize > MaxPullTotalSize {
return fmt.Errorf("tar archive exceeds maximum total size of %d bytes", MaxPullTotalSize)
}
if err := os.MkdirAll(filepath.Dir(entryPath), 0755); err != nil {
return fmt.Errorf("failed to create parent directory for '%s': %w", entryPath, err)
}
f, err := os.OpenFile(entryPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return fmt.Errorf("failed to create file '%s': %w", entryPath, err)
}View on GitHub (pinned to ea665308ba)
Solutions
- Verify the archive producer: only archive/tar or GNU tar output can produce valid sizes; regenerate the archive.
- Confirm the stream is not being misread (e.g. wrong offset — a seekable reader positioned mid-archive yields garbage headers).
- If the archive comes from an untrusted party, treat this rejection as working as intended — the extractor refused a malformed archive.
Defensive patterns
Strategy: validation
Validate before calling
// Producers: only emit archives via archive/tar or GNU tar; reject any // archive that fails a prior verification pass: // sha256sum bundle.tar # compare against expected digest before ExtractTar
Try / catch
err := flowfiles.ExtractTar(rc, destDir)
if err != nil {
if strings.Contains(err.Error(), "has invalid size") {
return fmt.Errorf("refusing malformed archive (negative entry size): %w", err)
}
return err
} Prevention
- Never hand-write tar headers; always produce archives with archive/tar or GNU tar.
- Authenticate/verify archives received from untrusted parties (signature or checksum).
- Treat this rejection as expected behavior — the extractor is defending against malformed input.
When it happens
Trigger: A tar header inside the stream read by PullFlowFiles declares a negative Size for a TypeReg/TypeRegA entry — only reachable with hand-crafted, corrupted, or non-conforming tar bytes.
Common situations: Practically only seen when feeding binary garbage that still parsed as a header, fuzzing, or a broken custom tar writer producing invalid headers.
Related errors
- failed to read tar entry: %w
- tar archive exceeds maximum file count of %d
- tar archive exceeds maximum total size of %d bytes
- path must be relative (no leading /)
- Internal
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/3eed76270c3c9f03.
Report an issue: GitHub.