{"record":{"id":"b5604fc63faa8b2b","repo":"apache/flink","slug":"error-untarring-file-infilepath-tar-process-exi","errorCode":null,"errorMessage":"Error untarring file {inFilePath}. Tar process exited with exit code {exitCode}","messagePattern":"Error untarring file (.+?)\\. Tar process exited with exit code (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java","lineNumber":141,"sourceCode":"    private static void extractTarFileUsingTar(\n            String inFilePath, String targetDirPath, boolean gzipped) throws IOException {\n        inFilePath = makeSecureShellPath(inFilePath);\n        targetDirPath = makeSecureShellPath(targetDirPath);\n        String untarCommand =\n                gzipped\n                        ? String.format(\n                                \"gzip -dc '%s' | (cd '%s' && tar -xf -)\", inFilePath, targetDirPath)\n                        : String.format(\"cd '%s' && tar -xf '%s'\", targetDirPath, inFilePath);\n        Process process = new ProcessBuilder(\"bash\", \"-c\", untarCommand).start();\n        int exitCode = 0;\n        try {\n            exitCode = process.waitFor();\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new IOException(\"Interrupted when untarring file \" + inFilePath);\n        }\n        if (exitCode != 0) {\n            throw new IOException(\n                    \"Error untarring file \"\n                            + inFilePath\n                            + \". Tar process exited with exit code \"\n                            + exitCode);\n        }\n    }\n\n    // Follow the pattern suggested in\n    // https://commons.apache.org/proper/commons-compress/examples.html\n    private static void extractTarFileUsingJava(\n            String inFilePath, String targetDirPath, boolean gzipped) throws IOException {\n        try (InputStream fi = Files.newInputStream(Paths.get(inFilePath));\n                InputStream bi = new BufferedInputStream(fi);\n                final TarArchiveInputStream tai =\n                        new TarArchiveInputStream(\n                                gzipped ? new GzipCompressorInputStream(bi) : bi)) {\n            final File targetDir = new File(targetDirPath);\n            TarArchiveEntry entry;","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java#L123-L159","documentation":"Thrown by extractTarFileUsingTar when the external `tar` process finishes with a non-zero exit code. The archive could not be unpacked by the system tar, and the reported exit code comes from tar/gzip itself (corrupt archive, unsupported format, gzip failure).","triggerScenarios":"Extracting a truncated or corrupt .tar/.tar.gz/.tgz file on Unix; a gzip stream with a bad CRC; a tar archive using features the installed tar rejects; disk full during extraction (tar exits non-zero).","commonSituations":"Partially downloaded distribution or plugin archive (interrupted download); archive corrupted in transit or by checkpointing to a bad disk; very old or exotic tar formats; a .gz-suffixed file that is not actually gzip.","solutions":["Verify the archive manually: `tar -tzf file.tar.gz` — if that fails the archive itself is bad","Re-download or regenerate the archive and compare checksums","Check disk space at the target location (df -h); tar exits non-zero when it cannot write","Confirm the file really matches its extension (file archive.tar.gz) — a misnamed zip will fail here when the suffix path falls back to tar"],"exampleFix":"// before\nCompressionUtils.extractTarFile(archivePath, targetDir);\n\n// after\nProcess p = new ProcessBuilder(\"tar\", \"-tzf\", archivePath).redirectErrorStream(true).start();\nif (p.waitFor() != 0) {\n    throw new IOException(\"Archive corrupt, re-download \" + archivePath);\n}\nCompressionUtils.extractTarFile(archivePath, targetDir);","handlingStrategy":"validation","validationCode":"try (ZipFile probe = new ZipFile(archivePath)) { /* format sanity */ }\n// or pre-verify with tar: exit code of `tar -tzf` must be 0 before extracting","typeGuard":null,"tryCatchPattern":"catch (IOException e) when message contains 'exit code': surface 'archive corrupt' to the operator with the archive's source/URL so it can be re-fetched.","preventionTips":["Verify checksums of downloaded archives before extraction","Ensure extraction targets have enough free disk space (tar writes then may fail with non-zero exit)"],"tags":["flink-core","compression","tar","corrupt-archive","process"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}