quarkusio/quarkus · error · IllegalArgumentException
File ${p} does not exist
Error message
File ${p} does not exist What it means
RegistriesConfigMapperHelper.deserialize(Path p, Class<T>) reads and parses a registry config file, but first requires the file to exist; passing a path that is not an existing regular file throws this IllegalArgumentException. It is a precondition check so callers get a clear message rather than a NoSuchFileException buried in YAML parsing.
Source
Thrown at independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigMapperHelper.java:67
if (!Files.exists(p.getParent())) {
Files.createDirectories(p.getParent());
}
try (BufferedWriter writer = Files.newBufferedWriter(p)) {
mapper(p).writeValue(writer, config);
}
}
public static void toJson(Object config, Writer writer) throws IOException {
jsonMapper().writeValue(writer, config);
}
public static void toYaml(Object config, Writer writer) throws IOException {
yamlMapper().writeValue(writer, config);
}
public static <T> T deserialize(Path p, Class<T> t) throws IOException {
if (!Files.exists(p)) {
throw new IllegalArgumentException("File " + p + " does not exist");
}
try (BufferedReader reader = Files.newBufferedReader(p)) {
return mapper(p).readValue(reader, t);
}
}
public static <T> T deserializeYaml(InputStream is, Class<T> t) throws IOException {
return yamlMapper().readValue(is, t);
}
public static <T> T deserializeYaml(Reader reader, Class<T> t) throws IOException {
return yamlMapper().readValue(reader, t);
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Check Files.exists(path) before calling deserialize and handle the missing case (use locateConfigYaml/createDefault if appropriate)
- Correct the path in the calling code — print path.toAbsolutePath() to confirm where it actually resolves
- Generate the config file if it should exist (e.g. by writing the default config before deserializing)
Example fix
// before
RegistriesConfig cfg = RegistriesConfigMapperHelper.deserialize(path, RegistriesConfig.class);
// after
if (!Files.exists(path)) {
path = RegistriesConfigLocator.locateConfigYaml(null);
}
RegistriesConfig cfg = RegistriesConfigMapperHelper.deserialize(path, RegistriesConfig.class); Defensive patterns
Strategy: validation
Validate before calling
if (p == null || !Files.isRegularFile(p)) {
p = RegistriesConfigLocator.locateConfigYaml(null);
} Try / catch
try {
return RegistriesConfigMapperHelper.deserialize(p, RegistriesConfig.class);
} catch (IllegalArgumentException | IOException e) {
logger.warn("Cannot read registry config {}: {}", p, e.getMessage());
return RegistriesConfigLocator.createDefault();
} Prevention
- Always obtain the path from RegistriesConfigLocator rather than constructing it by hand
- Check Files.isRegularFile (not just exists) to avoid directories
- Create a default config on first run before attempting to deserialize
When it happens
Trigger: Calling deserialize(p, RegistriesConfig.class) with a path that was never created, was deleted, or is a directory/symlink to a nonexistent target; locating a config path yourself and passing it in without an existence check.
Common situations: Custom tooling loading registries.yaml from a user-supplied path; tests pointing at a fixture file that is not on the test classpath/working directory; first-run scenarios where no default config has been generated yet.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- Unable to read file + path
- does not exist
- File does not exist: ${file}
- File is not a regular file: ${file}
- File cannot be read: ${file}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a5aa8541ca3b33f1.
Report an issue: GitHub.