{"record":{"id":"a065764b59a21f6e","repo":"plandex-ai/plandex","slug":"failed-to-read-tar-header-w","errorCode":null,"errorMessage":"failed to read tar header: %w","messagePattern":"failed to read tar header: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/upgrade.go","lineNumber":142,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to seek in temporary file: %w\", err)\n\t}\n\n\t// Now, extract the binary from the tempFile\n\tgzr, err := gzip.NewReader(tempFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create gzip reader: %w\", err)\n\t}\n\tdefer gzr.Close()\n\n\ttarReader := tar.NewReader(gzr)\n\tfor {\n\t\theader, err := tarReader.Next()\n\t\tif err == io.EOF {\n\t\t\tbreak // End of archive\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to read tar header: %w\", err)\n\t\t}\n\n\t\t// Check if the current file is the binary\n\t\tif header.Typeflag == tar.TypeReg && (header.Name == \"plandex\" || header.Name == \"plandex.exe\") {\n\t\t\terr = update.Apply(tarReader, update.Options{})\n\t\t\tif err != nil {\n\t\t\t\tif errors.Is(err, fs.ErrPermission) {\n\t\t\t\t\treturn fmt.Errorf(\"failed to apply update due to permission error; please try running your command again with 'sudo': %w\", err)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"failed to apply update: %w\", err)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/upgrade.go#L124-L160","documentation":"While iterating the extracted tar archive, tarReader.Next() advancing to the next header can return a non-EOF error; doUpgrade wraps it as 'failed to read tar header: %w'. This means the archive is corrupt partway through (usually a truncated or tampered download).","triggerScenarios":"The tar stream inside the gzip reader is malformed: the download was cut off mid-archive, the file was corrupted in transit, or a non-tar payload got this far (proxy-modified content).","commonSituations":"Flaky network dropping the connection mid-download so the file is truncated; disk corruption; MITM proxy rewriting content; CDN serving partial content.","solutions":["Retry the upgrade to re-download the archive.","Verify checksum of the downloaded release asset if possible.","Check for a proxy/VPN that truncates large transfers.","Download and install the release manually."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := tarReader.Next(); err != nil && err != io.EOF {\n\treturn fmt.Errorf(\"failed to read tar header: %w (archive may be truncated; retry the upgrade)\", err)\n}","preventionTips":["Retry the download once on archive parse failures","Verify Content-Length matched bytes written","Avoid untrusted/rewriting proxies for release downloads","Check disk health if corruption recurs"],"tags":["tar","archive","corrupt-download","go"],"backgroundTag":"corrupt-archive","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}