{"record":{"id":"1d10ffebdd8ba769","repo":"apache/flink","slug":"failed-to-create-parent-s-for-given-base-dir-s","errorCode":null,"errorMessage":"Failed to create parent(s) for given base dir: %s","messagePattern":"Failed to create parent\\(s\\) for given base dir: (.+?)","errorType":"exception","errorClass":"FlinkRuntimeException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/artifact/ArtifactUtils.java","lineNumber":49,"sourceCode":"public class ArtifactUtils {\n\n    private static final Logger LOG = LoggerFactory.getLogger(ArtifactUtils.class);\n\n    /**\n     * Creates missing parent directories for the given {@link File} if there are any. Does nothing\n     * otherwise.\n     *\n     * @param baseDir base dir to create parents for\n     */\n    public static synchronized void createMissingParents(File baseDir) {\n        checkNotNull(baseDir, \"Base dir has to be provided.\");\n\n        if (!baseDir.exists()) {\n            try {\n                FileUtils.forceMkdirParent(baseDir);\n                LOG.info(\"Created parents for base dir: {}\", baseDir);\n            } catch (Exception e) {\n                throw new FlinkRuntimeException(\n                        String.format(\"Failed to create parent(s) for given base dir: %s\", baseDir),\n                        e);\n            }\n        }\n    }\n\n    private ArtifactUtils() {\n        throw new UnsupportedOperationException(\"This class should never be instantiated.\");\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/artifact/ArtifactUtils.java#L31-L60","documentation":"Thrown when FileUtils.forceMkdirParent fails while creating parent directories for a base directory during artifact fetching. The method createMissingParents is called to ensure the artifact storage directory exists. The FlinkRuntimeException wraps the original exception and includes the base dir path.","triggerScenarios":"Calling ArtifactUtils.createMissingParents(baseDir) when the parent of baseDir cannot be created — due to permissions, a file (not directory) existing in the path, disk full, or a read-only filesystem.","commonSituations":"Container with a read-only volume mounted at the artifact path, insufficient permissions on the parent directory, or a path conflict where a file exists where a directory is expected.","solutions":["Ensure the artifact storage directory's parent is writable: 'ls -ld <parent>'.","Set the artifact directory to a writable location (e.g., a mounted emptyDir in K8s).","Remove any file blocking directory creation at the conflicting path.","Check disk space and inode availability on the target volume."],"exampleFix":"# before: read-only parent directory\nls -ld /opt/flink/artifacts\n# drwxr-xr-x root root (not writable by flink user)\n\n# after: use a writable directory\nmkdir -p /data/flink/artifacts\nchown flink:flink /data/flink/artifacts\n# set artifact directory config to /data/flink/artifacts","handlingStrategy":"validation","validationCode":"File parent = baseDir.getAbsoluteFile().getParentFile();\nif (parent != null && (!parent.exists() || !parent.canWrite())) {\n    throw new IllegalStateException(\n        \"Cannot create parents for \" + baseDir + \": parent not writable: \" + parent);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ArtifactUtils.createMissingParents(baseDir);\n} catch (FlinkRuntimeException e) {\n    if (e.getMessage().contains(\"Failed to create parent(s)\")) {\n        // check permissions and disk space on parent\n    }\n    throw e;\n}","preventionTips":["Ensure the artifact storage directory's parent is writable by the Flink user.","Mount a writable volume (e.g., emptyDir) at the artifact path in containers.","Avoid read-only filesystem mounts for artifact storage."],"tags":["artifact-utils","filesystem","permissions","io","directory"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}