{"record":{"id":"164f429b197d6495","repo":"github/copilot-sdk","slug":"expected-null-at-position-pos","errorCode":null,"errorMessage":"Expected null at position <pos>","messagePattern":"Expected null at position <pos>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java","lineNumber":1097,"sourceCode":"\n        private String parseBoolean() {\n            if (input.startsWith(\"true\", pos)) {\n                pos += 4;\n                return \"true\";\n            }\n            if (input.startsWith(\"false\", pos)) {\n                pos += 5;\n                return \"false\";\n            }\n            throw new IllegalArgumentException(\"Expected boolean at position \" + pos);\n        }\n\n        private String parseNull() {\n            if (input.startsWith(\"null\", pos)) {\n                pos += 4;\n                return \"(Object) null\";\n            }\n            throw new IllegalArgumentException(\"Expected null at position \" + pos);\n        }\n\n        private String parseNumber() {\n            int start = pos;\n            if (pos < input.length() && input.charAt(pos) == '-') {\n                pos++;\n            }\n            if (pos >= input.length()) {\n                throw new IllegalArgumentException(\"Expected number at position \" + start);\n            }\n            if (input.charAt(pos) == '0') {\n                pos++;\n            } else if (isDigitOneToNine(input.charAt(pos))) {\n                consumeDigits();\n            } else {\n                throw new IllegalArgumentException(\"Expected number at position \" + pos);\n            }\n            if (pos < input.length() && input.charAt(pos) == '.') {","sourceCodeStart":1079,"sourceCodeEnd":1115,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java#L1079-L1115","documentation":"The converter's null parser accepts only the exact lowercase literal 'null' at the current position; any other token raises this IllegalArgumentException. JSON null must be lowercase — 'None', 'NULL', or 'nil' are not valid.","triggerScenarios":"Parsing JSON containing 'None' (Python), 'NULL' (SQL/other languages), 'Nil', or an empty token where null is expected, e.g. '{\"value\":None}'.","commonSituations":"Serializing Python objects with str()/repr() instead of json.dumps (which turns None into null); templates that substitute NULL from SQL; hand-written JSON copying another language's null keyword.","solutions":["Replace the token with the lowercase JSON literal null","Use a proper serializer (Python: json.dumps, Java: Jackson) so None/NULL becomes null automatically","Check the reported position to identify which invalid null token appeared","Fix template/code that interpolates database NULLs directly into JSON"],"exampleFix":"// before\nString json = \"{\\\"value\\\":None}\"; // Python repr\n// after\nString json = \"{\\\"value\\\":null}\";","handlingStrategy":"validation","validationCode":"if (json.matches(\".*:\\\\s*(None|NULL|Nil)\\\\s*[,}\\\\]].*\")) {\n    throw new IllegalArgumentException(\"Non-JSON null literal found; use lowercase null\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    String result = CopilotToolProcessor.jsonToMapOfSource(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Expected null\")) {\n        // replace None/NULL/Nil with null and retry\n    }\n}","preventionTips":["JSON null is lowercase only; other languages' nulls must be converted (Python json.dumps maps None->null)","Never interpolate SQL NULL directly into JSON strings","Use proper serializers so null handling is automatic","Validate hand-written JSON with a reference parser"],"tags":["java","json","parsing","null"],"backgroundTag":"json-parse-error","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}