{"record":{"id":"7603399d4539421f","repo":"apache/flink","slug":"mkdirs-failed-to-create-tar-internal-dir-targetdi","errorCode":null,"errorMessage":"Mkdirs failed to create tar internal dir {targetDir}","messagePattern":"Mkdirs failed to create tar internal dir (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java","lineNumber":197,"sourceCode":"\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()) {\n            if (!outputFile.getParentFile().mkdirs()) {\n                throw new IOException(\"Mkdirs failed to create tar internal dir \" + targetDir);\n            }\n        }\n\n        try (OutputStream o = Files.newOutputStream(Paths.get(outputFile.getCanonicalPath()))) {\n            IOUtils.copyBytes(tis, o, false);\n        }\n    }\n\n    /**\n     * Convert a os-native filename to a path that works for the shell and avoids script injection\n     * attacks.\n     */\n    private static String makeSecureShellPath(String filePath) {\n        return filePath.replace(\"'\", \"'\\\\''\");\n    }\n\n    public static void extractZipFileWithPermissions(String zipFilePath, String targetPath)\n            throws IOException {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java#L179-L215","documentation":"Thrown when a tar file entry's parent directory does not exist and mkdirs() on it fails. Tar archives sometimes omit directory entries for a file's parents; Flink creates them on demand, and this error means that on-demand parent creation failed (permissions, disk, conflicting file).","triggerScenarios":"A tar without explicit directory entries (so getParentFile().mkdirs() is needed) extracted into a location where the parent chain cannot be created: no write permission, a file already exists somewhere along the path, or disk exhaustion.","commonSituations":"Extracting into a directory owned by another user; a previous partial extraction left a file where a directory is now needed; container image with read-only layer at the target path.","solutions":["Inspect the reported targetDir and the entry's parent chain for an existing non-directory file and remove it","Grant write permission to the extracting user on the whole target subtree","Extract into a clean directory to avoid residue from earlier failed runs"],"exampleFix":"// before\nCompressionUtils.extractTarFile(tar, \"/shared/readonly/dir\");\n\n// after\nFile target = new File(System.getProperty(\"java.io.tmpdir\"), \"flink-extract-\" + UUID.randomUUID());\nCompressionUtils.extractTarFile(tar, target.getAbsolutePath());","handlingStrategy":"validation","validationCode":"Path parent = Paths.get(targetDirPath).toAbsolutePath();\nif (!Files.isWritable(parent)) throw new IOException(\"Target not writable: \" + parent);","typeGuard":null,"tryCatchPattern":"catch (IOException e) and rethrow with target dir, archive path, and user running the process for quick permission diagnosis.","preventionTips":["Ensure the extracting process owns or can write the whole target subtree","Clean partial extractions before retrying so no stale file blocks a needed parent dir"],"tags":["flink-core","compression","filesystem","permissions","tar"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}