{"record":{"id":"9e7f7073a9a741cb","repo":"apache/flink","slug":"failed-to-create-directory-outputfile","errorCode":null,"errorMessage":"Failed to create directory {outputFile}","messagePattern":"Failed to create directory (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java","lineNumber":177,"sourceCode":"            TarArchiveEntry entry;\n            while ((entry = tai.getNextTarEntry()) != null) {\n                unpackEntry(tai, entry, targetDir);\n            }\n        }\n    }\n\n    private static void unpackEntry(\n            TarArchiveInputStream tis, TarArchiveEntry entry, File targetDir) throws IOException {\n        String targetDirPath = targetDir.getCanonicalPath() + File.separator;\n        File outputFile = new File(targetDir, entry.getName());\n        if (!outputFile.getCanonicalPath().startsWith(targetDirPath)) {\n            throw new IOException(\n                    \"expanding \" + entry.getName() + \" would create entry outside of \" + targetDir);\n        }\n\n        if (entry.isDirectory()) {\n            if (!outputFile.mkdirs() && !outputFile.isDirectory()) {\n                throw new IOException(\"Failed to create directory \" + outputFile);\n            }\n\n            for (TarArchiveEntry e : entry.getDirectoryEntries()) {\n                unpackEntry(tis, e, outputFile);\n            }\n\n            return;\n        }\n\n        if (entry.isSymbolicLink()) {\n            // create symbolic link relative to tar parent dir\n            Files.createSymbolicLink(\n                    Paths.get(new File(targetDir, entry.getName()).getCanonicalPath()),\n                    Paths.get(entry.getLinkName()));\n            return;\n        }\n\n        if (!outputFile.getParentFile().exists()) {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java#L159-L195","documentation":"Thrown while unpacking a tar entry that is a directory: File.mkdirs() returned false and the path is not an existing directory. The archive was validated (no traversal) but the filesystem refused to create the directory entry.","triggerScenarios":"A tar directory entry whose name cannot be created on the target filesystem: path too long, permission denied in the parent, a regular file already exists at that path, or an invalid name for the platform (e.g. reserved Windows names like CON, or entries containing ':').","commonSituations":"Extracting Linux-created archives on Windows hitting reserved characters; leftover file (not directory) at the entry path from a previous extraction; read-only or full target volume; deep nesting exceeding filesystem path limits.","solutions":["Check what already exists at the failing path: a stale regular file where a directory is expected must be removed","Extract to a fresh, empty target directory to avoid clashes with previous runs","On Windows, verify the entry name is legal (no ':' , not a reserved device name); consider extracting on a Unix-like filesystem","Confirm write permissions and path-length limits of the target filesystem"],"exampleFix":"// before\nCompressionUtils.extractTarFile(tarPath, reusedDirtyDir);\n\n// after\nFile target = new File(freshDir);\norg.apache.flink.util.FileUtils.deleteDirectoryQuietly(target); // or use a new dir per run\ntarget.mkdirs();\nCompressionUtils.extractTarFile(tarPath, target.getAbsolutePath());","handlingStrategy":"validation","validationCode":"File target = new File(targetDirPath);\nif (!target.exists() && !target.mkdirs()) throw new IOException(\"Cannot prepare \" + target);\nif (!target.canWrite()) throw new IOException(\"No write permission on \" + target);","typeGuard":null,"tryCatchPattern":"catch (IOException e) around extraction; include the failing entry name (from the message) plus target dir in the rethrown context.","preventionTips":["Extract into an empty, writable directory on each run","On Windows, avoid archives with entries using reserved names or ':' in paths"],"tags":["flink-core","compression","filesystem","tar","windows"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}