{"record":{"id":"0b149a85f0283211","repo":"quarkusio/quarkus","slug":"failed-to-determine-version-for-project-model","errorCode":null,"errorMessage":"Failed to determine version for project model","messagePattern":"Failed to determine version for project model","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/ModelUtils.java","lineNumber":157,"sourceCode":"                return groupId;\n            }\n        }\n        throw new IllegalStateException(\"Failed to determine groupId for project model\");\n    }\n\n    /**\n     * Returns the raw version of the model. This method returns the result of {@link #getRawVersionOrNull(Model)}\n     * except if it's null, it throws an exception.\n     *\n     * @param model POM\n     * @return raw model\n     */\n    public static String getRawVersion(Model model) {\n        String version = getRawVersionOrNull(model);\n        if (version != null) {\n            return version;\n        }\n        throw new IllegalStateException(\"Failed to determine version for project model\");\n    }\n\n    /**\n     * Returns the raw version of the model. If the model does not include\n     * the version directly and the coordinates of the parent artifact are configured,\n     * the parent version will be returned.\n     * If the parent coordinates are not configured, the method will return null.\n     * The version is raw in a sense if it's a property expression, the\n     * expression will not be resolved.\n     *\n     * @param model POM\n     * @return raw model\n     */\n    public static String getRawVersionOrNull(Model model) {\n        String version = model.getVersion();\n        if (version != null) {\n            return version;\n        }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/ModelUtils.java#L139-L175","documentation":"ModelUtils.getRawVersion(Model) returns the model's version, falling back to the parent's version; if neither is present it throws IllegalStateException. The bootstrap needs concrete coordinates for the project, and a POM without any version (own or inherited in the raw model) cannot be identified.","triggerScenarios":"Calling ModelUtils.getRawVersion/getVersion on a raw Model that has no <version> in the project element and no <parent> with <version> — e.g. a programmatically built Model, a minimal pom.xml missing the version, or the MISSING_MODEL placeholder.","commonSituations":"Generated POMs missing the version element; CI-friendly setups where the version was moved to properties but the element itself removed entirely; constructing Model objects in code and forgetting setVersion(); reading a POM whose parent block omits version (invalid for Maven too).","solutions":["Add <version> to the pom.xml project element (or ensure the <parent> block carries a version).","When building a Model in code, call model.setVersion(...) before handing it to the resolver.","Check ModelUtils.getRawVersionOrNull(model) != null before calling getRawVersion and handle the null case explicitly."],"exampleFix":"// before\nModel model = new Model();\nmodel.setGroupId(\"com.example\");\nString v = ModelUtils.getRawVersion(model); // IllegalStateException\n// after\nmodel.setVersion(\"1.0.0\");\nString v = ModelUtils.getRawVersion(model);","handlingStrategy":"validation","validationCode":"if (ModelUtils.getRawVersionOrNull(model) == null) {\n    throw new IllegalArgumentException(\"POM has no version (own or parent): \" + model.getPomFile());\n}\nString version = ModelUtils.getRawVersion(model);","typeGuard":"static boolean hasVersion(Model model) {\n    return model.getVersion() != null\n        || (model.getParent() != null && model.getParent().getVersion() != null);\n}","tryCatchPattern":"try {\n    String v = ModelUtils.getRawVersion(model);\n} catch (IllegalStateException e) {\n    // model has neither version nor parent version — repair the pom\n}","preventionTips":["Ensure every pom.xml has <version> in project or <parent>.","Use getRawVersionOrNull() when a missing version is acceptable.","For CI-friendly versions, keep the property-based <version> element present rather than removing it."],"tags":["maven","pom","invalid-model","quarkus-bootstrap"],"backgroundTag":"invalid-maven-pom","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}