quarkusio/quarkus · error · CodeGenException

Failed to list matching files in ${importPath}

Error message

Failed to list matching files in ${importPath}

What it means

AvroCodeGenProviderBase.gatherAllFiles walks the import path with Files.find to collect Avro input files; if the filesystem walk throws IOException the method wraps it in a CodeGenException with this message. This occurs during Quarkus code generation when the .avsc/.avdl/.avpr source directory cannot be scanned.

Source

Thrown at extensions/avro/deployment/src/main/java/io/quarkus/avro/deployment/AvroCodeGenProviderBase.java:94

        }

        return filesGenerated;
    }

    abstract void init();

    private Collection<Path> gatherAllFiles(Path importPath) throws CodeGenException {
        if (!Files.exists(importPath)) {
            return Collections.emptySet();
        }
        try {
            return Files.find(importPath, 20,
                    (path, ignored) -> Files.isRegularFile(path)
                            && Arrays.stream(inputExtensions()).anyMatch(ext -> path.toString().endsWith("." + ext)))
                    .map(Path::toAbsolutePath)
                    .collect(Collectors.toList());
        } catch (IOException e) {
            throw new CodeGenException("Failed to list matching files in " + importPath, e);
        }
    }

    abstract void compileSingleFile(Path importPath, Path outputDir, AvroOptions options) throws CodeGenException;

    public class AvroOptions {

        private final Config config;

        /**
         * A list of files or directories that should be compiled first thus making them
         * importable by subsequently compiled schemas. Note that imported files should
         * not reference each other.
         * <p>
         * All paths should be relative to the src/[main|test]/avro directory
         * <p>
         * Passed as a comma-separated list.
         */

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the Avro source directory exists and is readable relative to the module (e.g. src/main/avro)
  2. Fix filesystem permissions or remove broken symlinks under the import path
  3. Clean the build and regenerate so stale paths are refreshed
  4. Check quarkus avro codegen configuration for a wrong import path value

Example fix

// before
quarkus.generate.codegen.avro.import-path=src/main/schema // dir does not exist
// after
mkdir -p src/main/avro && put *.avsc there
quarkus.generate.codegen.avro.import-path=src/main/avro
Defensive patterns

Strategy: try-catch

Validate before calling

Path importPath = Paths.get("src/main/avro");
if (!Files.isDirectory(importPath) || !Files.isReadable(importPath)) {
    throw new IllegalStateException("Avro import path missing or unreadable: " + importPath);
}

Try / catch

try {
    List<Path> files = provider.trigger(context);
} catch (CodeGenException e) {
    logger.error("Check the Avro import directory exists and is readable", e);
}

Prevention

When it happens

Trigger: Code generation triggering over an importPath that is unreadable — nonexistent directory, permission problem, or I/O error while traversing (e.g. broken symlink, stale path during incremental builds).

Common situations: Configured avro codegen import directory missing or renamed; running build in a container without read permissions on the source dir; generated/symlinked directories removed between build phases.

Related errors


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