{"record":{"id":"d75a9c2938f48eb9","repo":"quarkusio/quarkus","slug":"the-tree-root-has-not-been-provided","errorCode":null,"errorMessage":"The tree root has not been provided","messagePattern":"The tree root has not been provided","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathTreeBuilder.java","lineNumber":68,"sourceCode":"    public PathTreeBuilder exclude(String expr) {\n        if (excludes == null) {\n            excludes = new ArrayList<>(1);\n        }\n        excludes.add(expr);\n        return this;\n    }\n\n    List<String> getExcludes() {\n        return excludes;\n    }\n\n    PathFilter getPathFilter() {\n        return includes == null && excludes == null ? null : new PathFilter(includes, excludes);\n    }\n\n    public PathTree build() {\n        if (root == null) {\n            throw new RuntimeException(\"The tree root has not been provided\");\n        }\n        if (!Files.exists(root)) {\n            throw new IllegalArgumentException(root + \" does not exist\");\n        }\n        if (archive) {\n            return ArchivePathTree.forPath(root, getPathFilter(), manifestEnabled == null ? true : manifestEnabled);\n        }\n        if (Files.isDirectory(root)) {\n            return new DirectoryPathTree(root, getPathFilter(), manifestEnabled == null ? false : manifestEnabled);\n        }\n        return new FilePathTree(root, getPathFilter());\n    }\n}\n","sourceCodeStart":50,"sourceCodeEnd":82,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathTreeBuilder.java#L50-L82","documentation":"PathTreeBuilder.build() throws RuntimeException('The tree root has not been provided') when neither a root path nor a roots collection was set on the builder before building. It is a programming/configuration mistake: the builder cannot construct a PathTree without a root.","triggerScenarios":"Calling build() on a PathTreeBuilder created without calling any root-setting method (e.g. PathTreeBuilder.builder().build()), or after root was reset/cleared.","commonSituations":"Programmatically building path trees from optional config where the config was absent, leaving the root null; refactoring that dropped the setRoot/setCurrentRoot call; conditional logic that skips root assignment on some code path.","solutions":["Call the builder's root setter (e.g. .setRoot(path)) before build().","Fail fast when configured source is missing: check config before building and skip or error explicitly.","Validate builder configuration with an assert/check prior to build().","Catch RuntimeException only at a boundary where a partially-configured builder is tolerated."],"exampleFix":"// before\nPathTree tree = PathTreeBuilder.builder().build(); // RuntimeException: no root\n// after\nif (cfg.sourceDir == null) {\n    throw new IllegalStateException(\"sourceDir must be configured\");\n}\nPathTree tree = PathTreeBuilder.builder().setRoot(cfg.sourceDir).build();","handlingStrategy":"validation","validationCode":"PathTreeBuilder builder = PathTreeBuilder.builder();\nif (root != null) {\n    builder.setRoot(root);\n} else {\n    throw new IllegalStateException(\"No root configured for path tree\");\n}\nPathTree tree = builder.build();","typeGuard":"static boolean isReadyToBuild(PathTreeBuilder b) {\n    return b != null && b.getRoot() != null; // if accessor available\n}","tryCatchPattern":"try {\n    PathTree tree = builder.build();\n} catch (RuntimeException e) {\n    if (\"The tree root has not been provided\".equals(e.getMessage())) {\n        throw new IllegalStateException(\"PathTreeBuilder used without setRoot(); check configuration wiring\", e);\n    }\n    throw e;\n}","preventionTips":["Always call setRoot(...) in the same expression chain as build().","Validate configuration before building; skip building entirely when the source is absent.","Avoid resetting/clearing builder state between setRoot and build.","Wrap builder construction in a small factory method that enforces root presence."],"tags":["runtime-exception","builder","quarkus-paths","missing-configuration"],"backgroundTag":"missing-required-config","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"}