{"record":{"id":"d40a65dc2b09bc46","repo":"quarkusio/quarkus","slug":"multiple-files-found-for-path-with-fail-on-duplic","errorCode":null,"errorMessage":"Multiple files found for path with 'fail-on-duplicate' FileStrategy: + relativePath","messagePattern":"Multiple files found for path with 'fail-on-duplicate' FileStrategy: \\+ relativePath","errorType":"exception","errorClass":"CodestartStructureException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/FailOnDuplicateCodestartFileStrategyHandler.java","lineNumber":28,"sourceCode":"import io.quarkus.devtools.codestarts.CodestartStructureException;\nimport io.quarkus.devtools.codestarts.core.reader.TargetFile;\n\nfinal class FailOnDuplicateCodestartFileStrategyHandler implements DefaultCodestartFileStrategyHandler {\n\n    static final String NAME = \"fail-on-duplicate\";\n\n    @Override\n    public String name() {\n        return NAME;\n    }\n\n    @Override\n    public void process(Path targetDirectory, String relativePath, List<TargetFile> codestartFiles, Map<String, Object> data)\n            throws IOException {\n        checkNotEmptyCodestartFiles(codestartFiles);\n        final Path targetPath = targetDirectory.resolve(relativePath);\n        if (codestartFiles.size() > 1 || Files.exists(targetPath)) {\n            throw new CodestartStructureException(\n                    \"Multiple files found for path with 'fail-on-duplicate' FileStrategy: \" + relativePath);\n        }\n        createDirectories(targetPath);\n        writeFile(targetPath, codestartFiles.get(0).getContent());\n    }\n\n    @Override\n    public void copyStaticFile(Source source, Path targetPath) throws IOException {\n        if (Files.exists(targetPath)) {\n            throw new CodestartStructureException(\n                    \"Multiple files found for path with 'fail-on-duplicate' FileStrategy: \" + source.absolutePath() + \":\"\n                            + targetPath);\n        }\n        Files.createDirectories(targetPath.getParent());\n\n        source.copyTo(targetPath);\n    }\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/FailOnDuplicateCodestartFileStrategyHandler.java#L10-L46","documentation":"FailOnDuplicateCodestartFileStrategyHandler.process throws CodestartStructureException when more than one codestart file maps to the same relativePath, or when the target file already exists in the target directory. This strategy is explicitly the strict option: any duplication or pre-existing target is a failure rather than a merge/override. The same message covers both conditions.","triggerScenarios":"Calling applyFile/codestart processing with 'fail-on-duplicate' strategy when (a) codestartFiles.size() > 1 for the same relativePath, or (b) targetDirectory.resolve(relativePath) already exists on disk.","commonSituations":"Two selected codestarts ship the same file path; re-applying a codestart into an already generated project; generated files left over from a previous partial run.","solutions":["Clean the target directory of the pre-existing file, or remove one of the duplicate source files in the codestarts","Switch the output strategy for that path to a permissive one (override, merge, or append) in the codestart definition","Regenerate the project from scratch in a fresh directory"],"exampleFix":"// before\ncodestarts: [base, custom]  // both provide config/app.properties, strategy: fail-on-duplicate\n\n// after\ncodestarts: [base, custom]  // custom: config/app.properties -> merge (or file removed from base)","handlingStrategy":"validation","validationCode":"if (codestartFiles.size() > 1)\n    throw new IllegalStateException(\"Duplicate providers for \" + relativePath);\nif (Files.exists(targetDirectory.resolve(relativePath)))\n    throw new IllegalStateException(\"Target exists: \" + relativePath);","typeGuard":null,"tryCatchPattern":"try {\n    handler.process(targetDir, relativePath, codestartFiles, data);\n} catch (CodestartStructureException e) {\n    if (e.getMessage().contains(\"fail-on-duplicate\")) {\n        // remove the pre-existing file or switch strategy to override/merge\n    } else throw e;\n}","preventionTips":["Never apply fail-on-duplicate codestarts twice into the same directory","Audit the codestart set for overlapping relative paths before generation","Generate into a fresh directory when using strict strategies"],"tags":["codestarts","duplicate-files","fail-on-duplicate"],"backgroundTag":"duplicate-codestart-file","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"}