{"record":{"id":"8c170a8235dfde3c","repo":"upstash/context7","slug":"unsupported-toml-escape-escape","errorCode":null,"errorMessage":"Unsupported TOML escape \\\\${escape}","messagePattern":"Unsupported TOML escape \\\\\\\\(.+?)","errorType":"validation","errorClass":null,"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/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/setup/toml-editor.ts#L36-L72","documentation":"Thrown by parseTomlBasicString when a backslash inside a TOML basic string starts an escape sequence that the parser does not recognize. TOML only permits a fixed set of short escapes (\\b \\t \\n \\f \\r \\\" \\\\) plus \\uXXXX and \\UXXXXXXXX; anything else is invalid TOML. This minimal parser throws rather than guessing at the intent.","triggerScenarios":"A double-quoted string in the MCP config args contains a backslash followed by a character outside the TOML escape set, e.g. \"C:\\Users\\foo\" (\\U... eventually fails) or \"a\\/b\".","commonSituations":"Windows file paths with unescaped backslashes; regexes like \"\\d+\" written for another language; shell-escape habits copied into TOML strings.","solutions":["Double every backslash intended as a literal backslash: \"C:\\\\Users\\\\foo\".","Use a single-quoted TOML literal string so backslashes are taken literally: 'C:\\Users\\foo'.","Replace the unknown escape with a supported one (\\n, \\t, \\r, \\b, \\f, \\\", \\\\, \\uXXXX, \\UXXXXXXXX).","For unicode, use the \\uXXXX (4 hex digits) or \\UXXXXXXXX (8 hex digits) form."],"exampleFix":"// before (config.toml)\nargs = [\"--path\", \"C:\\Users\\foo\"]\n// after\nargs = [\"--path\", \"C:\\\\Users\\\\foo\"]","handlingStrategy":"validation","validationCode":"const TOML_ESCAPES = new Set(['b','t','n','f','r','\"','\\\\','u','U']);\nfunction validEscapes(s) { return [...s.matchAll(/\\\\(.)/g)].every(([, c]) => TOML_ESCAPES.has(c)); }\nif (!args.every(a => typeof a === 'string' && validEscapes(a))) throw new Error('invalid TOML escape in args');","typeGuard":null,"tryCatchPattern":"try { parseConfig(toml); } catch (e) { if (e.message.startsWith('Unsupported TOML escape')) { console.error('Double the backslashes or use a literal single-quoted string:', e.message); } else throw e; }","preventionTips":["Double backslashes in double-quoted TOML strings","Prefer single-quoted literal strings for Windows paths and regexes","Only use the TOML escape set: \\b \\t \\n \\f \\r \\\" \\\\ \\uXXXX \\UXXXXXXXX","Lint the TOML file with a standard TOML parser before use"],"tags":["toml","parsing","escape-sequence","config"],"backgroundTag":"invalid-argument-format","analyzedSha":"4416fb855b8f752be735e34f943b5d0762701aad","analyzedAt":"2026-09-16T20:28:07.148Z","contentChangedAt":"2026-09-16T20:28:07.148Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}