{"record":{"id":"2d1894999c6cae25","repo":"reflex-dev/reflex","slug":"f-expected-escapesequence-to-have-a-single-rawtext","errorCode":null,"errorMessage":"f\"Expected EscapeSequence to have a single RawText child, got {children!r}\"","messagePattern":"f\"Expected EscapeSequence to have a single RawText child, got (.+?)\"","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-docgen/src/reflex_docgen/markdown/_parser.py","lineNumber":182,"sourceCode":"    if isinstance(token, Link):\n        return LinkSpan(children=_convert_children(token), target=token.target)\n\n    if isinstance(token, Image):\n        return ImageSpan(children=_convert_children(token), src=token.src)\n\n    if isinstance(token, LineBreak):\n        return LineBreakSpan(soft=token.soft)\n\n    if isinstance(token, EscapeSequence):\n        # EscapeSequence.children is a tuple of one RawText with the escaped char.\n        children = token.children\n        if (\n            not isinstance(children, tuple)\n            or len(children) != 1\n            or not isinstance(children[0], RawText)\n        ):\n            msg = f\"Expected EscapeSequence to have a single RawText child, got {children!r}\"\n            raise TypeError(msg)\n        return TextSpan(text=children[0].content)\n\n    msg = f\"Unsupported span token type: {type(token).__name__}\"\n    raise TypeError(msg)\n\n\ndef _convert_children(token: object) -> tuple[Span, ...]:\n    \"\"\"Convert the children of a mistletoe token into Spans.\n\n    Args:\n        token: A mistletoe token with a children attribute.\n\n    Returns:\n        A tuple of Span objects.\n    \"\"\"\n    children = getattr(token, \"children\", None)\n    if children is None:\n        return ()","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-docgen/src/reflex_docgen/markdown/_parser.py#L164-L200","documentation":"Similar to InlineCode, the docgen parser expects EscapeSequence tokens (backslash escapes) to wrap exactly one RawText child. Any deviation raises TypeError, and it is the final guard before the generic 'Unsupported span token type' error — so it fires only on structurally unexpected escapes, typically after a parser library upgrade.","triggerScenarios":"Parsing markdown with escape sequences (\\*, \\_) whose token tree has no single RawText child; version drift between mistletoe and reflex-docgen's expected AST shape.","commonSituations":"CI docgen after dependency refresh; docs containing heavy backslash escaping (regex examples, LaTeX-ish text).","solutions":["Rewrite the escaped markdown to avoid the edge case (e.g. use a code span instead of backslash escapes: `a\\*b`)","Restore the locked parser version: git checkout uv.lock && uv sync","Report upstream with the minimal markdown that triggers it"],"exampleFix":"# before\n# doc line: cost is 5\\*3 dollars\n# after\n# doc line: cost is `5*3` dollars","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    doc = parse_markdown(md_text)\nexcept TypeError as e:\n    logger.warning('escape sequence parse failed for %s: %s', path, e)\n    doc = parse_markdown(md_text.replace('\\\\', ''))","preventionTips":["Use code spans instead of backslash escapes in docs","Keep uv.lock pinned so parser AST shape stays stable"],"tags":["reflex","docgen","markdown","parser","escape-sequence"],"backgroundTag":"markdown-parser-unexpected-token","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}