{"record":{"id":"a5935246777e87fa","repo":"apple/pkl","slug":"ch","errorCode":null,"errorMessage":"'\" + ch + \"'","messagePattern":"'\" \\+ ch \\+ \"'","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java","lineNumber":240,"sourceCode":"    readRequiredChar('r');\n    readRequiredChar('u');\n    readRequiredChar('e');\n    handler.endBoolean(true);\n  }\n\n  private void readFalse() throws IOException {\n    handler.startBoolean();\n    read();\n    readRequiredChar('a');\n    readRequiredChar('l');\n    readRequiredChar('s');\n    readRequiredChar('e');\n    handler.endBoolean(false);\n  }\n\n  private void readRequiredChar(char ch) throws IOException {\n    if (!readChar(ch)) {\n      throw expected(\"'\" + ch + \"'\");\n    }\n  }\n\n  private void readString() throws IOException {\n    handler.startString();\n    handler.endString(readStringInternal());\n  }\n\n  private String readStringInternal() throws IOException {\n    read();\n    startCapture();\n    while (current != '\"') {\n      if (current == '\\\\') {\n        pauseCapture();\n        readEscape();\n        startCapture();\n      } else if (current < 0x20) {\n        throw expected(\"valid string character\");","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/json/JsonParser.java#L222-L258","documentation":"The literals true, false, and null must be spelled exactly. readTrue, readFalse, and readNull each call readRequiredChar for their remaining letters; when the next character does not match, readRequiredChar throws expected(\"'<ch>'\"). The message interpolates the expected character, e.g. expected 'r' for a malformed \"true\".","triggerScenarios":"parse() on inputs like \"tru\", \"True\", \"FALSE\", \"nul\", or a literal truncated mid-word (e.g. stream cut off after \"fal\"), where readRequiredChar finds a mismatching character or EOF.","commonSituations":"Case-typed booleans (True/False from Python style), truncated network responses, template variables left empty mid-literal (\"tru${x}\"), search-and-replace accidents in config files.","solutions":["Spell literals in lowercase exactly: true, false, null — JSON is case-sensitive.","Check the ParseException position to see which literal was misspelled or truncated and fix the source.","If input may be truncated, verify completeness (e.g. content-length check or a final validation pass) before parsing.","Catch ParseException around parse() and surface a friendly 'invalid literal' message."],"exampleFix":"// before\nString json = \"{\\\"ok\\\": True}\"; // Python-style capitalization\n// after\nString json = \"{\\\"ok\\\": true}\";","handlingStrategy":"validation","validationCode":"// Java: check literals are exactly lowercase before parsing\nif (java.util.regex.Pattern.compile(\"\\\\b(True|False|TRUE|FALSE|NULL|None)\\\\b\").matcher(json).find()) {\n  throw new IllegalArgumentException(\"JSON literals must be exactly: true, false, null\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  parser.parse(json);\n} catch (ParseException e) {\n  if (e.getMessage().matches(\"expected '[a-z]'\")) {\n    throw new IllegalArgumentException(\"Misspelled true/false/null literal at \" + e.getLocation().line + \":\" + e.getLocation().column, e);\n  }\n  throw e;\n}","preventionTips":["Use exactly true, false, null (lowercase) in JSON.","Convert booleans with the language's JSON serializer, not manual string building.","Verify input completeness to avoid truncated literals.","Grep generated files for True/False/None before parsing."],"tags":["json","parser","syntax-error","pkl"],"backgroundTag":"json-parse-error","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}