{"record":{"id":"c64edd65ebbd885c","repo":"OpenAPITools/openapi-generator","slug":"failed-to-create-the-folder-parent-getabsolute","errorCode":null,"errorMessage":"Failed to create the folder \" + parent.getAbsolutePath() + \" to store the checksum of the input spec.","messagePattern":"Failed to create the folder \" \\+ parent\\.getAbsolutePath\\(\\) \\+ \" to store the checksum of the input spec\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java","lineNumber":1130,"sourceCode":"                            + langCliOption.getOptionHelp().replaceAll(\"\\n\", \"\\n\\t    \"));\n                    System.out.println();\n                }\n                return;\n            }\n            adjustAdditionalProperties(config);\n            GlobalSettings.log();\n            new DefaultGenerator(dryRun).opts(input).generate();\n\n            if (buildContext != null) {\n                buildContext.refresh(new File(getCompileSourceRoot()));\n            }\n\n            // Store a checksum of the input spec\n            File storedInputSpecHashFile = getHashFile(inputSpecFile);\n            if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {\n                File parent = new File(storedInputSpecHashFile.getParent());\n                if (!parent.mkdirs()) {\n                    throw new RuntimeException(\"Failed to create the folder \" + parent.getAbsolutePath() +\n                            \" to store the checksum of the input spec.\");\n                }\n            }\n\n            Files.asCharSink(storedInputSpecHashFile, StandardCharsets.UTF_8).write(calculateInputSpecHash(inputSpec));\n        } catch (Exception e) {\n            // Maven logs exceptions thrown by plugins only if invoked with -e\n            // I find it annoying to jump through hoops to get basic diagnostic information,\n            // so let's log it in any case:\n            if (buildContext != null) {\n                buildContext.addMessage(inputSpecFile, 0, 0, \"unexpected error in Open-API generation\", BuildContext.SEVERITY_WARNING, e);\n            }\n            getLog().error(e);\n            throw new MojoExecutionException(\n                    \"Code generation failed. See above for the full exception.\");\n        }\n    }\n","sourceCodeStart":1112,"sourceCodeEnd":1148,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java#L1112-L1148","documentation":"After generation succeeds, CodeGenMojo stores a SHA-256 checksum of the input spec for incremental builds; this RuntimeException (not MojoExecutionException) means File.mkdirs() returned false while creating the parent directory of that checksum file (typically under output/src/main/java/... or the configured output plus .openapi-generator). mkdirs returns false both when creation fails (permissions, read-only mount) and when the path exists as a file or another thread created it concurrently — the code does not distinguish, and the raw RuntimeException then surfaces as 'unexpected error in Open-API generation'.","triggerScenarios":"output directory on a read-only filesystem or one the build user cannot write; a file already exists where the directory should be (e.g. a stray file named like the folder); parallel Maven builds (mvn -T) racing two executions into the same output dir; container/CI environments with non-writable mounted volumes.","commonSituations":"Dockerized builds with a read-only or root-owned volume; CI caching that restored a file where the checksum directory belongs; highly parallel builds sharing one generated-sources directory; NFS/network mounts with flaky mkdir semantics.","solutions":["Check the parent path printed in the message: if a file occupies it, delete/rename the file and rerun.","Ensure the build user has write permission on the whole output directory tree (chmod/chown, or fix the volume mount in Docker).","Give each parallel execution its own <output> directory, or disable module-level parallelism for modules running this plugin.","Run mvn clean to remove a stale directory structure before regenerating."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# fail fast if the plugin output tree is not writable\nOUT=$(mvn -q help:evaluate -Dexpression=openapi.output -DforceStdout 2>/dev/null || echo target/generated-sources)\nmkdir -p \"$OUT\" 2>/dev/null || { echo \"cannot create $OUT\"; exit 1; }\n[ -w \"$OUT\" ] || { echo \"$OUT is not writable\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the build user owns the plugin <output> tree; avoid read-only mounts for generated sources.","Do not check generated directories into git as read-only files.","Give each parallel Maven execution (-T) its own output directory to avoid mkdirs races.","Run mvn clean after restoring CI caches that may have replaced directories with files."],"tags":["openapi-generator","maven","filesystem","permissions","checksum","parallel-builds"],"backgroundTag":"cannot-create-directory","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}