{"record":{"id":"720bb6d1f45813e1","repo":"OpenAPITools/openapi-generator","slug":"code-generation-failed-see-above-for-the-full-exc","errorCode":null,"errorMessage":"Code generation failed. See above for the full exception.","messagePattern":"Code generation failed\\. See above for the full exception\\.","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java","lineNumber":1144,"sourceCode":"            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\n    /**\n     * Calculate an SHA256 hash for the openapi specification.\n     * If the specification is hosted on a remote resource it is downloaded first.\n     *\n     * @param inputSpec - Openapi specification input file. Can denote a URL or file path.\n     * @return openapi specification hash\n     */\n    private String calculateInputSpecHash(String inputSpec) {\n        final ParseOptions parseOptions = new ParseOptions();\n        parseOptions.setResolve(true);\n\n        final URL remoteUrl = inputSpecRemoteUrl();\n        final List<AuthorizationValue> authorizationValues = AuthParser.parse(this.auth);\n","sourceCodeStart":1126,"sourceCodeEnd":1162,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java#L1126-L1162","documentation":"Catch-all wrapper at the end of CodeGenMojo's generation method: any Exception thrown by DefaultGenerator.opts(...).generate() or the checksum bookkeeping — invalid OpenAPI document, unsupported option for the chosen generator, missing template files, unwritable output, network failure fetching a remote spec — is logged via getLog().error(e) and rethrown as this MojoExecutionException. The message deliberately says 'see above' because the root cause is the logged exception, not this wrapper.","triggerScenarios":"Any downstream failure during generation: spec with invalid references (unresolved $ref), generator-specific configOptions rejected by the generator, missing/locked template files, output collision with existing read-only files, remote inputSpec URL unreachable, or the checksum RuntimeException from the same method.","commonSituations":"CI builds where the real stack trace scrolled past; upgrading the plugin and hitting changed option names; specs that pass YAML parsing but violate OpenAPI schema rules; generated-code directories checked into git as read-only.","solutions":["Rerun with mvn -e (the comment in the source notes Maven only shows plugin stack traces with -e) and read the first 'unexpected error in Open-API generation' / logged exception above this message — that is the real cause.","Validate the spec first: run the validate goal (openapi-generator:validate) or openapi-generator-cli validate on the same input.","Check generator-specific options against the generator's documentation (mvn ...:config-help or openapi-generator-cli config-help -g <name>).","If the cause is environmental (permissions, network for remote specs), fix that resource and rerun."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# pre-flight the spec and options before the build\nopenapi-generator-cli validate -i src/main/resources/openapi.yaml\nopenapi-generator-cli config-help -g java | grep -i '<optionYouUse>'","typeGuard":null,"tryCatchPattern":"# CI wrapper: run the goal, and on failure re-print the root cause section\nmvn openapi-generator:generate -e || {\n  grep -B2 -A40 'unexpected error in Open-API generation' build.log || true\n  exit 1\n}","preventionTips":["Always build with -e (or -X) when this plugin runs; the wrapper hides the cause otherwise.","Run the validate goal before generate in CI to catch spec issues with clearer messages.","Pin the plugin version and re-check configOptions after upgrades — most wrapped failures are rejected options or spec rules.","Treat 'Code generation failed' as a pointer, not a diagnosis: the real exception is logged just above."],"tags":["openapi-generator","maven","wrapper-exception","code-generation","diagnostics"],"backgroundTag":"code-generation-failed","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}