apache/flink · error · IOException

Create dir: {outputFile.getAbsolutePath()} failed!

Error message

Create dir: {outputFile.getAbsolutePath()} failed!

What it means

Thrown while extracting a zip entry that is a directory: the entry does not already exist and mkdirs() failed. The path passed traversal validation, so this is a filesystem-level failure creating the directory (permissions, conflicting file, invalid name, disk issue).

Source

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

            boolean isUnix = isUnix();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            String canonicalTargetPath = new File(targetPath).getCanonicalPath() + File.separator;

            while (entries.hasMoreElements()) {
                ZipArchiveEntry entry = entries.nextElement();
                File outputFile = new File(canonicalTargetPath, entry.getName());
                if (!outputFile.getCanonicalPath().startsWith(canonicalTargetPath)) {
                    throw new IOException(
                            "Expand "
                                    + entry.getName()
                                    + " would create a file outside of "
                                    + targetPath);
                }

                if (entry.isDirectory()) {
                    if (!outputFile.exists()) {
                        if (!outputFile.mkdirs()) {
                            throw new IOException(
                                    "Create dir: " + outputFile.getAbsolutePath() + " failed!");
                        }
                    }
                } else {
                    File parentDir = outputFile.getParentFile();
                    if (!parentDir.exists()) {
                        if (!parentDir.mkdirs()) {
                            throw new IOException(
                                    "Create dir: " + outputFile.getAbsolutePath() + " failed!");
                        }
                    }
                    if (entry.isUnixSymlink()) {
                        // the content of the file is the target path of the symlink
                        baos.reset();
                        IOUtils.copyBytes(zipFile.getInputStream(entry), baos);
                        Files.createSymbolicLink(
                                outputFile.toPath(), new File(parentDir, baos.toString()).toPath());
                    } else if (outputFile.createNewFile()) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Check the exact path in the message with ls/dir — remove any regular file squatting on a directory path
  2. Extract into a new empty directory instead of reusing one
  3. Fix permissions or free disk space on the target volume
  4. On Windows, verify the zip does not contain OS-illegal names

Example fix

// before
CompressionUtils.extractZipFileWithPermissions(zip, existingDirtyDir);

// after
File clean = Files.createTempDirectory("unzip").toFile();
CompressionUtils.extractZipFileWithPermissions(zip, clean.getAbsolutePath());
Defensive patterns

Strategy: validation

Validate before calling

File target = new File(targetPath);
if (target.exists() && !target.isDirectory()) throw new IOException(target + " is a file");
if (!target.exists() && !target.mkdirs()) throw new IOException("Cannot create " + target);

Try / catch

catch (IOException e) around extractZipFileWithPermissions and rethrow including the absolute failing path.

Prevention

When it happens

Trigger: extractZipFileWithPermissions encounters a directory entry whose mkdirs() returns false: read-only target, an existing regular file at the same path, or an entry name illegal on the OS (Windows reserved names/characters).

Common situations: Re-extracting over a dirty target dir where files replaced directories; insufficient permissions in the install dir; Windows reserved names like `CON`, `PRN`, or `:` in entry names; disk full.

Related errors


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