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: + relativePath

What it means

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.

Source

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

import io.quarkus.devtools.codestarts.CodestartStructureException;
import io.quarkus.devtools.codestarts.core.reader.TargetFile;

final class FailOnDuplicateCodestartFileStrategyHandler implements DefaultCodestartFileStrategyHandler {

    static final String NAME = "fail-on-duplicate";

    @Override
    public String name() {
        return NAME;
    }

    @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. Clean the target directory of the pre-existing file, or remove one of the duplicate source files in the codestarts
  2. Switch the output strategy for that path to a permissive one (override, merge, or append) in the codestart definition
  3. Regenerate the project from scratch in a fresh directory

Example fix

// before
codestarts: [base, custom]  // both provide config/app.properties, strategy: fail-on-duplicate

// after
codestarts: [base, custom]  // custom: config/app.properties -> merge (or file removed from base)
Defensive patterns

Strategy: validation

Validate before calling

if (codestartFiles.size() > 1)
    throw new IllegalStateException("Duplicate providers for " + relativePath);
if (Files.exists(targetDirectory.resolve(relativePath)))
    throw new IllegalStateException("Target exists: " + relativePath);

Try / catch

try {
    handler.process(targetDir, relativePath, codestartFiles, data);
} catch (CodestartStructureException e) {
    if (e.getMessage().contains("fail-on-duplicate")) {
        // remove the pre-existing file or switch strategy to override/merge
    } else throw e;
}

Prevention

When it happens

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

Common situations: 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.

Related errors


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