prestodb/presto · error · IllegalArgumentException
Invalid JSON file '%s' for '%s'
Error message
Invalid JSON file '%s' for '%s'
What it means
JsonUtils.parseJson reads a file fully into memory and deserializes it into javaType via Jackson with FAIL_ON_UNKNOWN_PROPERTIES enabled. Any IOException — unreadable file, malformed JSON, or a type mismatch surfaced as an IO failure — becomes an IllegalArgumentException naming the path and target type.
Source
Thrown at presto-plugin-toolkit/src/main/java/com/facebook/presto/plugin/base/JsonUtils.java:49
private JsonUtils() {}
public static <T> T parseJson(Path path, Class<T> javaType)
{
if (!path.isAbsolute()) {
path = path.toAbsolutePath();
}
checkArgument(exists(path), "File does not exist: %s", path);
checkArgument(isReadable(path), "File is not readable: %s", path);
try {
byte[] json = Files.readAllBytes(path);
ObjectMapper mapper = new JsonObjectMapperProvider().get()
.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
return mapper.readValue(json, javaType);
}
catch (IOException e) {
throw new IllegalArgumentException(format("Invalid JSON file '%s' for '%s'", path, javaType), e);
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the file path exists and is readable by the Presto process user
- Validate the JSON with a linter (jq < file) to find syntax errors
- Compare the JSON fields against the target Java type; remove unknown or renamed properties
- Check whether a version upgrade changed the expected schema for this file
Example fix
// before
return mapper.readValue(json, javaType); // throws on unknown props
// after
ObjectMapper mapper = new JsonObjectMapperProvider().get()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
return mapper.readValue(json, javaType); Defensive patterns
Strategy: validation
Validate before calling
# shell pre-check before pointing the plugin at the file jq empty /etc/presto/my-config.json && test -r /etc/presto/my-config.json && echo OK
Try / catch
try {
MyConfig cfg = JsonUtils.parseJson(path, MyConfig.class);
} catch (IllegalArgumentException e) {
log.error("bad JSON config " + path, e.getCause());
throw e;
} Prevention
- Run jq/yamllint-style validation in deployment scripts before restart
- Keep config JSON under schema validation in CI
- Ensure the Presto process user has read access to config files
- Diff config fields against the expected type after upgrades
When it happens
Trigger: parseJson(path, javaType) is given a path that does not exist or is unreadable, or a file whose content is not valid JSON, or JSON that Jackson cannot map to the requested type while FAIL_ON_UNKNOWN_PROPERTIES is enabled.
Common situations: Typos in the JSON rules/policy file path in plugin config; hand-edited JSON with a trailing comma; config schema drift after a version upgrade added/renamed fields.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/73476c5883730f8c.
Report an issue: GitHub.