{"record":{"id":"3eed76270c3c9f03","repo":"vxcontrol/pentagi","slug":"tar-entry-s-has-invalid-size-d","errorCode":null,"errorMessage":"tar entry '%s' has invalid size %d","messagePattern":"tar entry '(.+?)' has invalid size (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/flowfiles/files.go","lineNumber":403,"sourceCode":"\t\t\treturn fmt.Errorf(\"failed to read tar entry: %w\", err)\n\t\t}\n\t\tif hdr.Typeflag == tar.TypeSymlink || hdr.Typeflag == tar.TypeLink {\n\t\t\tcontinue\n\t\t}\n\n\t\tentryPath := filepath.Join(destDir, filepath.Clean(filepath.FromSlash(hdr.Name)))\n\t\tif !IsWithinDir(entryPath, destDir) {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch hdr.Typeflag {\n\t\tcase tar.TypeDir:\n\t\t\tif err := os.MkdirAll(entryPath, 0755); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create directory '%s': %w\", entryPath, err)\n\t\t\t}\n\t\tcase tar.TypeReg, tar.TypeRegA:\n\t\t\tif hdr.Size < 0 {\n\t\t\t\treturn fmt.Errorf(\"tar entry '%s' has invalid size %d\", hdr.Name, hdr.Size)\n\t\t\t}\n\t\t\tfilesCount++\n\t\t\tif filesCount > MaxPullFiles {\n\t\t\t\treturn fmt.Errorf(\"tar archive exceeds maximum file count of %d\", MaxPullFiles)\n\t\t\t}\n\t\t\ttotalSize += hdr.Size\n\t\t\tif totalSize > MaxPullTotalSize {\n\t\t\t\treturn fmt.Errorf(\"tar archive exceeds maximum total size of %d bytes\", MaxPullTotalSize)\n\t\t\t}\n\n\t\t\tif err := os.MkdirAll(filepath.Dir(entryPath), 0755); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create parent directory for '%s': %w\", entryPath, err)\n\t\t\t}\n\n\t\t\tf, err := os.OpenFile(entryPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create file '%s': %w\", entryPath, err)\n\t\t\t}","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/flowfiles/files.go#L385-L421","documentation":"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.","triggerScenarios":"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.","commonSituations":"Practically only seen when feeding binary garbage that still parsed as a header, fuzzing, or a broken custom tar writer producing invalid headers.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Producers: only emit archives via archive/tar or GNU tar; reject any\n// archive that fails a prior verification pass:\n//   sha256sum bundle.tar  # compare against expected digest before ExtractTar","typeGuard":null,"tryCatchPattern":"err := flowfiles.ExtractTar(rc, destDir)\nif err != nil {\n    if strings.Contains(err.Error(), \"has invalid size\") {\n        return fmt.Errorf(\"refusing malformed archive (negative entry size): %w\", err)\n    }\n    return err\n}","preventionTips":["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."],"tags":["tar","validation","corruption","security"],"backgroundTag":"invalid-tar-archive","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}