{"record":{"id":"a2437cd5f7e7479b","repo":"upstash/context7","slug":"invalid-toml-unicode-code-point-u-hex","errorCode":null,"errorMessage":"Invalid TOML Unicode code point U+${hex}","messagePattern":"Invalid TOML Unicode code point U\\+(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":64,"sourceCode":"    }\n\n    const escape = source[index++];\n    if (Object.hasOwn(TOML_BASIC_ESCAPES, escape)) {\n      value += TOML_BASIC_ESCAPES[escape];\n      continue;\n    }\n    if (escape !== \"u\" && escape !== \"U\") {\n      throw new Error(`Unsupported TOML escape \\\\${escape}`);\n    }\n\n    const width = escape === \"u\" ? 4 : 8;\n    const hex = source.slice(index, index + width);\n    if (!new RegExp(`^[0-9A-Fa-f]{${width}}$`).test(hex)) {\n      throw new Error(`Invalid TOML Unicode escape \\\\${escape}${hex}`);\n    }\n    const codePoint = Number.parseInt(hex, 16);\n    if (codePoint > 0x10ffff || (codePoint >= 0xd800 && codePoint <= 0xdfff)) {\n      throw new Error(`Invalid TOML Unicode code point U+${hex}`);\n    }\n    value += String.fromCodePoint(codePoint);\n    index += width;\n  }\n  throw new Error(\"Unterminated TOML basic string in MCP args\");\n}\n\nfunction parseTomlLiteralString(source: string, start: number): TomlStringToken {\n  const endQuote = source.indexOf(\"'\", start + 1);\n  if (endQuote === -1) throw new Error(\"Unterminated TOML literal string in MCP args\");\n  const value = source.slice(start + 1, endQuote);\n  if (value.includes(\"\\n\") || value.includes(\"\\r\")) {\n    throw new Error(\"Multiline strings are not supported in MCP args\");\n  }\n  return { value, start, end: endQuote + 1 };\n}\n\nfunction parseTomlStringArray(","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L46-L82","documentation":"A \\u/\\U escape had valid hex digits but the resulting code point is invalid: greater than U+10FFFF or inside the surrogate range U+D800–U+DFFF, which Unicode forbids as scalar values.","triggerScenarios":"args containing \\UD800AAAA, \\uDFFF0000, or \\U00110000+.","commonSituations":"Copy-pasting surrogate pair halves from JSON \\uD83D\\ude00-style escapes (TOML requires the combined code point, e.g. \\U0001F600); typos in 8-digit escapes.","solutions":["Replace surrogate pairs with the single combined code point (\\U0001F600 instead of \\uD83D\\ude00)","Keep code points ≤ U+10FFFF and outside D800–DFFF","Avoid emojis/symbols in machine args unless correctly escaped"],"exampleFix":"// before\nargs = [\"\\uD83D\\ude00\"]\n// after\nargs = [\"\\U0001F600\"]","handlingStrategy":"validation","validationCode":"for (const m of s.matchAll(/\\\\u([0-9A-Fa-f]{4})|\\\\U([0-9A-Fa-f]{8})/g)) {\n  const cp = parseInt(m[1] ?? m[2], 16);\n  if (cp > 0x10ffff || (cp >= 0xd800 && cp <= 0xdfff)) throw new Error('surrogate/OOB code point');\n}","typeGuard":"function isValidScalarEscape(hex: string): boolean {\n  const cp = parseInt(hex, 16);\n  return cp <= 0x10ffff && !(cp >= 0xd800 && cp <= 0xdfff);\n}","tryCatchPattern":"catch (e) { if (/code point/.test(e.message)) { /* replace surrogate pairs with combined \\U escape */ } throw e; }","preventionTips":["Never paste raw \\uD8xx/\\uDCxx pairs from JSON","Use codePointAt-based generators for escapes"],"tags":["toml","unicode","surrogate","escape-sequence"],"backgroundTag":"invalid-unicode-code-point","analyzedSha":"edc9eeb77bbfc553e08a122ca783293fdb477daf","analyzedAt":"2026-08-28T10:18:41.476Z","contentChangedAt":"2026-08-28T10:18:41.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}