{"record":{"id":"5be52ae6bd0b7a3b","repo":"github/copilot-sdk","slug":"invalid-unicode-escape-at-position-pos-1","errorCode":null,"errorMessage":"Invalid Unicode escape at position <pos-1>","messagePattern":"Invalid Unicode escape at position <pos-1>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java","lineNumber":1068,"sourceCode":"                case 'f' -> '\\f';\n                case 'n' -> '\\n';\n                case 'r' -> '\\r';\n                case 't' -> '\\t';\n                case 'u' -> parseUnicodeEscape();\n                default -> throw new IllegalArgumentException(\n                        \"Invalid escape sequence \\\\\" + escaped + \" at position \" + (pos - 2));\n            };\n        }\n\n        private char parseUnicodeEscape() {\n            if (pos + 4 > input.length()) {\n                throw new IllegalArgumentException(\"Incomplete Unicode escape at position \" + (pos - 2));\n            }\n            int value = 0;\n            for (int i = 0; i < 4; i++) {\n                char hex = input.charAt(pos++);\n                if (!isAsciiHexDigit(hex)) {\n                    throw new IllegalArgumentException(\"Invalid Unicode escape at position \" + (pos - 1));\n                }\n                int digit = Character.digit(hex, 16);\n                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;","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java#L1050-L1086","documentation":"parseUnicodeEscape expects four ASCII hex digits after \\u. One of the four characters read was not a valid hex digit (0-9, a-f, A-F), so the escape is malformed. The error reports the position of the offending character (pos-1).","triggerScenarios":"Escapes like '\\u00zz', '\\u 0e9', or '\\u+123' inside a JSON string — anything where one of the four chars after \\u is outside [0-9a-fA-F].","commonSituations":"Hand-written Unicode escapes with typos; placeholders like '\\uXXXX' left unsubstituted by a template engine; mistaken use of '\\u' with decimal or signed values.","solutions":["Correct the escape to contain exactly four hex digits, e.g. '\\u00e9'","If the intent was a literal '\\uXXXX' placeholder, escape the backslash: '\\\\uXXXX'","Inspect the character at the reported position to identify the typo","Prefer a JSON serializer (it emits valid escapes or raw UTF-8) over manual escaping"],"exampleFix":"// before\nString json = \"{\\\"ch\\\":\\\"\\\\u00zz\\\"}\"; // z not hex\n// after\nString json = \"{\\\"ch\\\":\\\"\\\\u00e9\\\"}\";","handlingStrategy":"try-catch","validationCode":"java.util.regex.Matcher m = java.util.regex.Pattern.compile(\"\\\\\\\\\\\\\\\\u(?![0-9a-fA-F]{4})\").matcher(json);\nif (m.find()) {\n    throw new IllegalArgumentException(\"Non-hex digit in \\\\u escape at index \" + m.start());\n}","typeGuard":null,"tryCatchPattern":"try {\n    String result = CopilotToolProcessor.jsonToMapOfSource(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid Unicode escape\")) {\n        // correct the hex digits at the reported position\n    }\n}","preventionTips":["Verify \\u escapes contain only [0-9a-fA-F]","Search generated payloads for literal 'XXXX' placeholders that were never substituted","Use decimal code points only as digits after \\u (\\u00e9, not \\u233)","Round-trip generated JSON through a reference parser before use"],"tags":["java","json","parsing","unicode","escaping"],"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-15T23:17:13.987Z"}