{"record":{"id":"117ba8d2ff28f8ac","repo":"upstash/context7","slug":"invalid-toml-unicode-escape-escape-hex","errorCode":null,"errorMessage":"Invalid TOML Unicode escape \\\\${escape}${hex}","messagePattern":"Invalid TOML Unicode escape \\\\\\\\(.+?)(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":60,"sourceCode":"    }\n    if (char !== \"\\\\\") {\n      value += char;\n      continue;\n    }\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  }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L42-L78","documentation":"A \\u or \\U unicode escape was found in a double-quoted string, but the characters following it are not the required 4 (for \\u) or 8 (for \\U) hex digits. Example: \\u12 or \\U00GG0000.","triggerScenarios":"args = [\"\\u12\"] (too few digits), \\uZZZZ (non-hex letters), or a \\U truncated by the end of line/string.","commonSituations":"Emacs/JS-style \\u escapes with fewer than 4 digits; hand-shortening unicode escapes; a \\U escape accidentally cut off when editing the line.","solutions":["Provide exactly 4 hex digits after \\u and 8 after \\U","Use only 0-9, A-F, a-f in the escape","If you meant a literal backslash+u, double the backslash or use a single-quoted string"],"exampleFix":"// before\nargs = [\"\\u12\"]\n// after\nargs = [\"\\u0012\"]","handlingStrategy":"validation","validationCode":"const re = /\\\\u([0-9A-Fa-f]{0,3})(?![0-9A-Fa-f])|\\\\U([0-9A-Fa-f]{0,7})(?![0-9A-Fa-f])/g;\nif (re.test(s)) throw new Error('Short/invalid unicode escape');","typeGuard":"function hasValidUnicodeEscapes(s: string): boolean {\n  return !/\\\\u(?![0-9A-Fa-f]{4})(?!.)/.test(s.replace(/\\\\u[0-9A-Fa-f]{4}/g, ''))\n    && !/\\\\U(?![0-9A-Fa-f]{8})/.test(s);\n}","tryCatchPattern":"catch (e) { if (/Invalid TOML Unicode escape/.test(e.message)) { /* pad \\u to 4 / \\U to 8 hex digits */ } throw e; }","preventionTips":["Always write 4 digits after \\u, 8 after \\U","Generate escapes programmatically rather than by hand"],"tags":["toml","unicode-escape","string-parsing"],"backgroundTag":"toml-invalid-escape","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"}