{"record":{"id":"c0bcecc2d61983c0","repo":"quarkusio/quarkus","slug":"failed-to-read-model","errorCode":null,"errorMessage":"Failed to read model","messagePattern":"Failed to read model","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/MojoUtils.java","lineNumber":173,"sourceCode":"     * @param dependencies The plugin extensions\n     * @return The plugin instance\n     */\n    public static Plugin plugin(String groupId, String artifactId, String version, List<Dependency> dependencies) {\n        Plugin plugin = new Plugin();\n        plugin.setArtifactId(artifactId);\n        plugin.setGroupId(groupId);\n        plugin.setVersion(version);\n        plugin.setDependencies(dependencies);\n        return plugin;\n    }\n\n    public static Model readPom(final File pom) throws IOException {\n        try {\n            return Maven.readModel(pom.toPath());\n        } catch (UncheckedIOException e) {\n            throw e.getCause();\n        } catch (RuntimeException e) {\n            throw new IOException(\"Failed to read model\", e.getCause());\n        }\n    }\n\n    public static Model readPom(final InputStream resourceAsStream) throws IOException {\n        try (InputStream is = resourceAsStream) {\n            return Maven.readModel(is);\n        } catch (UncheckedIOException e) {\n            throw e.getCause();\n        } catch (RuntimeException e) {\n            throw new IOException(\"Failed to read model\", e.getCause());\n        }\n    }\n\n    public static String[] readGavFromPom(final InputStream resourceAsStream) throws IOException {\n        Model model = readPom(resourceAsStream);\n        return new String[] { model.getGroupId(), model.getArtifactId(), model.getVersion() };\n    }\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/MojoUtils.java#L155-L191","documentation":"MojoUtils.readPom(File) wraps any non-IO runtime failure from Maven.readModel into an IOException with message 'Failed to read model'. It indicates the pom.xml could not be parsed into a Maven Model (malformed XML, unreadable file, unsupported model).","triggerScenarios":"Calling MojoUtils.readPom(File) on a file that is missing, unreadable, or not a well-formed pom.xml; Maven.readModel throws a RuntimeException whose cause is chained.","commonSituations":"Corrupted or hand-edited pom.xml with invalid XML, wrong file path passed in, encoding problems (invalid bytes for declared charset), or a truncated file.","solutions":["Verify the file path points to an existing pom.xml","Validate the XML is well-formed (open in an editor or run mvn help:effective-pom)","Check file read permissions for the process user","Inspect the chained cause (getCause) for the underlying parse error"],"exampleFix":"// before\nModel m = MojoUtils.readPom(new File(\"src/pom.xml\")); // wrong path\n// after\nFile pom = new File(\"pom.xml\");\nif (!pom.isFile()) throw new IllegalStateException(\"pom.xml missing\");\nModel m = MojoUtils.readPom(pom);","handlingStrategy":"validation","validationCode":"if (pom == null || !pom.isFile() || !pom.canRead()) {\n    throw new IllegalStateException(\"pom.xml missing or unreadable: \" + pom);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Model m = MojoUtils.readPom(pomFile);\n} catch (IOException e) {\n    throw new UncheckedIOException(\"Cannot parse \" + pomFile + \": check XML validity\", e);\n}","preventionTips":["Confirm the pom path exists and is a file before reading","Keep pom.xml XML well-formed; run mvn help:effective-pom in CI to catch corruption","Always log the chained cause for diagnosis","Handle encoding consistently (UTF-8) across the project"],"tags":["maven","io","pom-parsing"],"backgroundTag":"pom-parse-failure","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}