{"record":{"id":"73476c5883730f8c","repo":"prestodb/presto","slug":"invalid-json-file-s-for-s","errorCode":null,"errorMessage":"Invalid JSON file '%s' for '%s'","messagePattern":"Invalid JSON file '(.+?)' for '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-plugin-toolkit/src/main/java/com/facebook/presto/plugin/base/JsonUtils.java","lineNumber":49,"sourceCode":"    private JsonUtils() {}\n\n    public static <T> T parseJson(Path path, Class<T> javaType)\n    {\n        if (!path.isAbsolute()) {\n            path = path.toAbsolutePath();\n        }\n\n        checkArgument(exists(path), \"File does not exist: %s\", path);\n        checkArgument(isReadable(path), \"File is not readable: %s\", path);\n\n        try {\n            byte[] json = Files.readAllBytes(path);\n            ObjectMapper mapper = new JsonObjectMapperProvider().get()\n                    .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);\n            return mapper.readValue(json, javaType);\n        }\n        catch (IOException e) {\n            throw new IllegalArgumentException(format(\"Invalid JSON file '%s' for '%s'\", path, javaType), e);\n        }\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":53,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-plugin-toolkit/src/main/java/com/facebook/presto/plugin/base/JsonUtils.java#L31-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nreturn mapper.readValue(json, javaType); // throws on unknown props\n// after\nObjectMapper mapper = new JsonObjectMapperProvider().get()\n        .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);\nreturn mapper.readValue(json, javaType);","handlingStrategy":"validation","validationCode":"# shell pre-check before pointing the plugin at the file\njq empty /etc/presto/my-config.json && test -r /etc/presto/my-config.json && echo OK","typeGuard":null,"tryCatchPattern":"try {\n    MyConfig cfg = JsonUtils.parseJson(path, MyConfig.class);\n} catch (IllegalArgumentException e) {\n    log.error(\"bad JSON config \" + path, e.getCause());\n    throw e;\n}","preventionTips":["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"],"tags":["presto","json","configuration","file-io"],"backgroundTag":"invalid-json-file","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}