quarkusio/quarkus · error · CodestartStructureException

Multiple files found for path with 'fail-on-duplicate' FileS

Error message

Multiple files found for path with 'fail-on-duplicate' FileStrategy: + source.absolutePath() + ":" + targetPath

What it means

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.

Source

Thrown at independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/FailOnDuplicateCodestartFileStrategyHandler.java:38

    }

    @Override
    public void process(Path targetDirectory, String relativePath, List<TargetFile> codestartFiles, Map<String, Object> data)
            throws IOException {
        checkNotEmptyCodestartFiles(codestartFiles);
        final Path targetPath = targetDirectory.resolve(relativePath);
        if (codestartFiles.size() > 1 || Files.exists(targetPath)) {
            throw new CodestartStructureException(
                    "Multiple files found for path with 'fail-on-duplicate' FileStrategy: " + relativePath);
        }
        createDirectories(targetPath);
        writeFile(targetPath, codestartFiles.get(0).getContent());
    }

    @Override
    public void copyStaticFile(Source source, Path targetPath) throws IOException {
        if (Files.exists(targetPath)) {
            throw new CodestartStructureException(
                    "Multiple files found for path with 'fail-on-duplicate' FileStrategy: " + source.absolutePath() + ":"
                            + targetPath);
        }
        Files.createDirectories(targetPath.getParent());

        source.copyTo(targetPath);
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the existing target file before re-applying the codestart
  2. Remove the static file from one of the codestarts or change its output strategy to override
  3. Use a fresh target directory for generation

Example fix

// before
File already present: target/README.md; copying base/README.md again -> throws

// after
rm target/README.md   // or set output-strategy: override for README.md
Defensive patterns

Strategy: validation

Validate before calling

Path targetPath = targetDir.resolve(sourceRelativePath);
if (Files.exists(targetPath)) {
    throw new IllegalStateException("Static copy would overwrite: " + targetPath);
}

Try / catch

try {
    handler.copyStaticFile(source, targetPath);
} catch (CodestartStructureException e) {
    if (e.getMessage().startsWith("Multiple files found")) {
        // message contains source.absolutePath()+targetPath — resolve the collision there
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Re-running codestart generation on an existing project; two codestarts shipping identical static resources (README, .gitignore) at the same path.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/db3125281093ba23. Report an issue: GitHub.