{"record":{"id":"8545f11305622185","repo":"quarkusio/quarkus","slug":"codestartfiles-must-not-be-null-or-empty","errorCode":null,"errorMessage":"codestartFiles must not be null or empty","messagePattern":"codestartFiles must not be null or empty","errorType":"exception","errorClass":"CodestartStructureException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategyHandler.java","lineNumber":41,"sourceCode":"                    new AppendCodestartFileStrategyHandler(),\n                    new ContentMergeCodestartFileStrategyHandler(),\n                    new ExecutableFileStrategyHandler(),\n                    new ReplaceCodestartFileStrategyHandler(),\n                    new ForbiddenCodestartFileStrategyHandler(),\n                    new SmartConfigMergeCodestartFileStrategyHandler(),\n                    new SmartPomMergeCodestartFileStrategyHandler(),\n                    new SmartPackageFileStrategyHandler(),\n                    new DockerComposeCodestartFileStrategyHandler())\n            .collect(Collectors.toMap(CodestartFileStrategyHandler::name, Function.identity()));\n\n    String name();\n\n    void process(Path targetDirectory, String relativePath, List<TargetFile> codestartFiles, Map<String, Object> data)\n            throws IOException;\n\n    default void checkNotEmptyCodestartFiles(List<TargetFile> codestartFiles) {\n        if (codestartFiles == null || codestartFiles.isEmpty()) {\n            throw new CodestartStructureException(\"codestartFiles must not be null or empty\");\n        }\n    }\n\n    default void checkTargetDoesNotExist(Path targetPath) {\n        if (Files.exists(targetPath)) {\n            throw new CodestartStructureException(\n                    \"Target file already exists: \" + targetPath.toString());\n        }\n    }\n\n    default void createDirectories(Path targetPath) throws IOException {\n        Files.createDirectories(targetPath.getParent());\n    }\n\n    default void writeFile(final Path targetPath, final String content) throws IOException {\n        if (!SKIP_FILE_IDENTIFIER.equals(content)) {\n            Files.write(targetPath, content.getBytes(StandardCharsets.UTF_8));\n        }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategyHandler.java#L23-L59","documentation":"CodestartFileStrategyHandler.checkNotEmptyCodestartFiles is a shared guard used by file strategy handlers before processing conflict resolution. It throws when the list of candidate TargetFiles for a path is null or empty, which would make strategy processing meaningless. This indicates an internal inconsistency in collected codestart files rather than user data format.","triggerScenarios":"A custom or built-in strategy handler invokes process/check with no files collected for a given relative path during generation; upstream file collection returned nothing for a filter match.","commonSituations":"Custom CodestartFileStrategyHandler implementations forgetting the empty-list guard; codestart selectors matching a strategy but producing zero files; bugs in file reader chains.","solutions":["Call checkNotEmptyCodestartFiles(files) at the top of your custom handler's process() and skip/no-op when empty","Investigate why the file collection step produced an empty list for that relative path (filters, selectors)","Update to a Quarkus version fixing the strategy that generated empty file lists"],"exampleFix":"// before\n@Override\npublic void process(...) throws IOException {\n    Path target = targetDirectory.resolve(relativePath);\n    Files.write(target, codestartFiles.get(0).getContent().getBytes());\n}\n// after\n@Override\npublic void process(...) throws IOException {\n    checkNotEmptyCodestartFiles(codestartFiles);\n    Path target = targetDirectory.resolve(relativePath);\n    Files.write(target, codestartFiles.get(0).getContent().getBytes());\n}","handlingStrategy":"validation","validationCode":"if (files == null || files.isEmpty()) return; // skip handler invocation","typeGuard":null,"tryCatchPattern":"try { handler.process(dir, rel, files, data); }\ncatch (CodestartStructureException e) {\n    if (\"codestartFiles must not be null or empty\".equals(e.getMessage())) { /* guard handler */ }\n    else throw e;\n}","preventionTips":["Guard custom handlers against empty lists","Verify filters match collected files","Test empty-input paths"],"tags":["codestart","internal","invariant-violation"],"backgroundTag":"empty-file-list","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"}