{"record":{"id":"9b17f6f0da9242ab","repo":"quarkusio/quarkus","slug":"unable-to-read-json-constant-for-s","errorCode":null,"errorMessage":"Unable to read json constant for: %s","messagePattern":"Unable to read json constant for: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/builder/src/main/java/io/quarkus/builder/JsonReader.java","lineNumber":316,"sourceCode":"        return isFraction;\n    }\n\n    private void ignoreDigits() {\n        while (position < length) {\n            final int ch = peekChar();\n            if (!Character.isDigit(ch)) {\n                break;\n            }\n            position++;\n        }\n    }\n\n    private JsonValue readConstant(String expected, JsonValue result) {\n        if (text.regionMatches(position, expected, 0, expected.length())) {\n            position += expected.length();\n            return result;\n        }\n        throw new IllegalArgumentException(\"Unable to read json constant for: \" + expected);\n    }\n\n    /**\n     * ws\n     * |---- \"\"\n     * |---- '0020' ws\n     * |---- '000A' ws\n     * |---- '000D' ws\n     * |---- '0009' ws\n     */\n    private void ignoreWhitespace() {\n        while (position < length) {\n            final int ch = peekChar();\n            switch (ch) {\n                case ' ': // '0020' SPACE\n                case '\\n': // '000A' LINE FEED\n                case '\\r': // '000D' CARRIAGE RETURN\n                case '\\t': // '0009' CHARACTER TABULATION","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/builder/src/main/java/io/quarkus/builder/JsonReader.java#L298-L334","documentation":"readConstant(expected, result) matches a literal keyword (true, false, null) at the current parser position. If the text at that position does not exactly equal the expected constant, it throws this IllegalArgumentException. It means the parser expected the JSON keyword `expected` but found different characters there.","triggerScenarios":"Parsing JSON where a value position contains a misspelled or truncated keyword, e.g. \"tru\", \"falsee\", \"nil\", or an identifier like \"True\"/\"NULL\" instead of the exact lowercase true/false/null that readValue dispatched to readConstant.","commonSituations":"Hand-written JSON with casing mistakes (True, FALSE) borrowed from other languages; templated JSON with an unfilled placeholder where the keyword should be; truncated documents cutting a keyword short; typos in generated JSON.","solutions":["Use the exact lowercase JSON keywords: true, false, null (not True, TRUE, nil, None).","Inspect the input at the reported position and correct or complete the misspelled keyword.","Validate the JSON with a standard parser to find all malformed values at once.","Fix any template/generation step that emits placeholders or truncated output where the keyword belongs."],"exampleFix":"// before\nString json = \"{\\\"flag\\\":True}\"; // not a JSON keyword\n\n// after\nString json = \"{\\\"flag\\\":true}\";","handlingStrategy":"validation","validationCode":"// ensure only exact lowercase JSON keywords are used\nboolean hasValidConstants(String json) {\n    return !json.matches(\"(?i).*[^\\\\\\\"]?(True|False|TRUE|FALSE|None|nil|NULL)[^\\\\\\\"]?.*\")\n        || json.matches(\".*\\\\b(true|false|null)\\\\b.*\");\n}\n// simpler: pre-validate with a standard JSON parser before JsonReader","typeGuard":null,"tryCatchPattern":"try {\n    JsonReader.parse(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unable to read json constant\")) {\n        throw new ConfigException(\"Invalid JSON keyword; only lowercase true/false/null are accepted\", e);\n    }\n    throw e;\n}","preventionTips":["Always use lowercase true/false/null in JSON","Validate JSON with a standard parser before custom parsing","Check templates/generators for unfilled placeholders where keywords should appear"],"tags":["json","parser","syntax-error"],"backgroundTag":"malformed-json-input","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}