{"record":{"id":"f3dd7f6a73a3480b","repo":"github/copilot-sdk","slug":"expected-boolean-at-position-pos","errorCode":null,"errorMessage":"Expected boolean at position <pos>","messagePattern":"Expected boolean at position <pos>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java","lineNumber":1089,"sourceCode":"                value = (value << 4) | digit;\n            }\n            return (char) value;\n        }\n\n        private boolean isAsciiHexDigit(char c) {\n            return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');\n        }\n\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            }","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java#L1071-L1107","documentation":"The converter's boolean parser only accepts the exact literals 'true' or 'false' at the current position; anything else raises this IllegalArgumentException. It is the strict-JSON equivalent of 'not a valid boolean here'.","triggerScenarios":"Parsing JSON containing misspelled booleans ('True', 'TRUE', 'yes', '1', 'on') where a boolean is expected, e.g. '{\"flag\":True}'.","commonSituations":"JSON hand-built from Python (whose True/False are capitalized) via str()/repr(); shells or configs exporting 'yes'/'no'; string 'true' left unquoted-but-stringified or numeric 0/1 used for booleans.","solutions":["Replace the value with the lowercase JSON literals true or false","If the source is Python, use json.dumps() instead of str() to serialize dicts","If the value is really a string like \"yes\", quote it and convert in application code","Check the reported position to find the offending token"],"exampleFix":"// before\nString json = \"{\\\"enabled\\\":True}\"; // Python-style\n// after\nString json = \"{\\\"enabled\\\":true}\"; // JSON literal","handlingStrategy":"validation","validationCode":"if (json.matches(\".*:\\\\s*(True|TRUE|yes|no|on|off)\\\\s*[,}\\\\]].*\")) {\n    throw new IllegalArgumentException(\"Non-JSON boolean literal found; use lowercase true/false\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    String result = CopilotToolProcessor.jsonToMapOfSource(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Expected boolean\")) {\n        // replace Python/other-language boolean literals with true/false and retry\n    }\n}","preventionTips":["In Python, always use json.dumps() (never str()/repr()) to produce JSON","JSON booleans are only lowercase true and false — no yes/no/1/0","Convert yes/no configs to booleans before serialization","Lint hand-written JSON with a strict parser"],"tags":["java","json","parsing","boolean"],"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"}