{"record":{"id":"db3125281093ba23","repo":"quarkusio/quarkus","slug":"multiple-files-found-for-path-with-fail-on-duplic-db3125","errorCode":null,"errorMessage":"Multiple files found for path with 'fail-on-duplicate' FileStrategy: + source.absolutePath() + \":\" + targetPath","messagePattern":"Multiple files found for path with 'fail-on-duplicate' FileStrategy: \\+ source\\.absolutePath\\(\\) \\+ \":\" \\+ targetPath","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":38,"sourceCode":"    }\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\n}\n","sourceCodeStart":20,"sourceCodeEnd":48,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/FailOnDuplicateCodestartFileStrategyHandler.java#L20-L48","documentation":"FailOnDuplicateCodestartFileStrategyHandler.copyStaticFile throws CodestartStructureException when copying a static (non-template) source file to targetPath and the target already exists. Unlike process(), the message includes the source absolute path and target path so the two colliding files can be located. This prevents the strategy from overwriting an existing file during a plain file copy.","triggerScenarios":"Calling copyStaticFile with 'fail-on-duplicate' strategy when Files.exists(targetPath) is true — i.e. a previous codestart/file already wrote that exact target location.","commonSituations":"Re-running codestart generation on an existing project; two codestarts shipping identical static resources (README, .gitignore) at the same path.","solutions":["Delete the existing target file before re-applying the codestart","Remove the static file from one of the codestarts or change its output strategy to override","Use a fresh target directory for generation"],"exampleFix":"// before\nFile already present: target/README.md; copying base/README.md again -> throws\n\n// after\nrm target/README.md   // or set output-strategy: override for README.md","handlingStrategy":"validation","validationCode":"Path targetPath = targetDir.resolve(sourceRelativePath);\nif (Files.exists(targetPath)) {\n    throw new IllegalStateException(\"Static copy would overwrite: \" + targetPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n    handler.copyStaticFile(source, targetPath);\n} catch (CodestartStructureException e) {\n    if (e.getMessage().startsWith(\"Multiple files found\")) {\n        // message contains source.absolutePath()+targetPath — resolve the collision there\n    } else throw e;\n}","preventionTips":["Compare source.absolutePath()+\":\"+targetPath in the message to find exactly which two files collide","Delete stale generated files before re-running static copies","Prefer override strategy for static files intended to be idempotent"],"tags":["codestarts","duplicate-files","static-files"],"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-14T00:17:10.932Z"}