{"record":{"id":"8c170a8235dfde3c","repo":"upstash/context7","slug":"unsupported-toml-escape-escape","errorCode":null,"errorMessage":"Unsupported TOML escape \\\\${escape}","messagePattern":"Unsupported TOML escape \\\\\\\\(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":54,"sourceCode":"  let index = start + 1;\n  while (index < source.length) {\n    const char = source[index++];\n    if (char === '\"') return { value, start, end: index };\n    if (char === \"\\n\" || char === \"\\r\") {\n      throw new Error(\"Multiline strings are not supported in MCP args\");\n    }\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 {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L36-L72","documentation":"The parser hit a backslash escape inside a double-quoted TOML string that it does not support. Only the standard TOML escapes (b, t, n, f, r, quote, backslash) plus \\u and \\U unicode escapes are handled; anything else (e.g. \\x, \\0, \\d) is rejected.","triggerScenarios":"A double-quoted args string containing an escape like \"\\x41\", \"\\d+\", or a Windows-style path written as \"C:\\Users\" (where \\U is treated as a unicode escape start or fails).","commonSituations":"Writing regex patterns or Windows paths in args without doubling backslashes; copy-pasting JSON/JS escape syntax into TOML; using \\x hex escapes that TOML doesn't have.","solutions":["Double the backslash for literal backslashes: \"C:\\\\Users\\\\me\"","Use only supported escapes: \\n \\t \\r \\f \\b \\\" \\\\ or \\uXXXX / \\UXXXXXXXX","For regexes, use a literal single-quoted TOML string ('...') where backslashes are literal"],"exampleFix":"// before\nargs = [\"--path\", \"C:\\Users\\me\"]\n// after\nargs = [\"--path\", \"C:\\\\Users\\\\me\"]","handlingStrategy":"validation","validationCode":"const ALLOWED = ['b','t','n','f','r','\"','\\\\\\\\','u','U'];\nconst re = /\\\\([^btnfr\"\\\\uU])/g;\nif (re.test(str)) throw new Error('Unsupported escape: ' + re.exec(str)?.[1]);","typeGuard":"function hasOnlySupportedTomlEscapes(s: string): boolean {\n  return !/\\\\[^btnfr\"\\\\uU]/.test(s);\n}","tryCatchPattern":"catch (e) { if (/Unsupported TOML escape/.test(e.message)) { /* rewrite escapes or use literal string */ } throw e; }","preventionTips":["Prefer single-quoted literal strings for regexes/paths","Double backslashes in basic strings","Escape via JSON.parse round-trip tooling carefully"],"tags":["toml","escape-sequence","string-parsing","mcp"],"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-14T05:17:10.506Z"}