apache/flink · error · IOException

Error untarring file {inFilePath}. Tar process exited with e

Error message

Error untarring file {inFilePath}. Tar process exited with exit code {exitCode}

What it means

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).

Source

Thrown at flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java:141

    private static void extractTarFileUsingTar(
            String inFilePath, String targetDirPath, boolean gzipped) throws IOException {
        inFilePath = makeSecureShellPath(inFilePath);
        targetDirPath = makeSecureShellPath(targetDirPath);
        String untarCommand =
                gzipped
                        ? String.format(
                                "gzip -dc '%s' | (cd '%s' && tar -xf -)", inFilePath, targetDirPath)
                        : String.format("cd '%s' && tar -xf '%s'", targetDirPath, inFilePath);
        Process process = new ProcessBuilder("bash", "-c", untarCommand).start();
        int exitCode = 0;
        try {
            exitCode = process.waitFor();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new IOException("Interrupted when untarring file " + inFilePath);
        }
        if (exitCode != 0) {
            throw new IOException(
                    "Error untarring file "
                            + inFilePath
                            + ". Tar process exited with exit code "
                            + exitCode);
        }
    }

    // Follow the pattern suggested in
    // https://commons.apache.org/proper/commons-compress/examples.html
    private static void extractTarFileUsingJava(
            String inFilePath, String targetDirPath, boolean gzipped) throws IOException {
        try (InputStream fi = Files.newInputStream(Paths.get(inFilePath));
                InputStream bi = new BufferedInputStream(fi);
                final TarArchiveInputStream tai =
                        new TarArchiveInputStream(
                                gzipped ? new GzipCompressorInputStream(bi) : bi)) {
            final File targetDir = new File(targetDirPath);
            TarArchiveEntry entry;

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Verify the archive manually: `tar -tzf file.tar.gz` — if that fails the archive itself is bad
  2. Re-download or regenerate the archive and compare checksums
  3. Check disk space at the target location (df -h); tar exits non-zero when it cannot write
  4. 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

Example fix

// before
CompressionUtils.extractTarFile(archivePath, targetDir);

// after
Process p = new ProcessBuilder("tar", "-tzf", archivePath).redirectErrorStream(true).start();
if (p.waitFor() != 0) {
    throw new IOException("Archive corrupt, re-download " + archivePath);
}
CompressionUtils.extractTarFile(archivePath, targetDir);
Defensive patterns

Strategy: validation

Validate before calling

try (ZipFile probe = new ZipFile(archivePath)) { /* format sanity */ }
// or pre-verify with tar: exit code of `tar -tzf` must be 0 before extracting

Try / catch

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.

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/b5604fc63faa8b2b. Report an issue: GitHub.