{"record":{"id":"afa6096c3c15fa4d","repo":"3b1b/manim","slug":"missing-inserted-afa609","errorCode":null,"errorMessage":"Missing '}' inserted","messagePattern":"Missing '\\}' inserted","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/svg/tex_mobject.py","lineNumber":127,"sourceCode":"                    (open_start, open_end), index = open_stack.pop()\n                    n = min(open_end - open_start, close_end - close_start)\n                    result.insert(index, pattern.fullmatch(\n                        string, pos=open_end - n, endpos=open_end\n                    ))\n                    result.append(pattern.fullmatch(\n                        string, pos=close_start, endpos=close_start + n\n                    ))\n                    close_start += n\n                    if close_start < close_end:\n                        continue\n                    open_end -= n\n                    if open_start < open_end:\n                        open_stack.append(((open_start, open_end), index))\n                    break\n            else:\n                result.append(match_obj)\n        if open_stack:\n            raise ValueError(\"Missing '}' inserted\")\n        return result\n\n    @staticmethod\n    def get_command_flag(match_obj: re.Match) -> int:\n        if match_obj.group(\"open\"):\n            return 1\n        if match_obj.group(\"close\"):\n            return -1\n        return 0\n\n    @staticmethod\n    def replace_for_content(match_obj: re.Match) -> str:\n        return match_obj.group()\n\n    @staticmethod\n    def replace_for_matching(match_obj: re.Match) -> str:\n        if match_obj.group(\"command\"):\n            return match_obj.group()","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/svg/tex_mobject.py#L109-L145","documentation":"Raised at the end of the same brace-matching pass (tex_mobject.py:127) when the LaTeX string ends with opening braces that were never closed — the open_stack is non-empty after scanning. It is the mirror of 'Missing {': the string has more '{' than matching '}'.","triggerScenarios":"MathTex(r'{') or MathTex(r'\\sqrt{a') raises; also substring isolation like MathTex(r'\\frac{a}{b}', substrings_to_isolate=['\\frac{']) where the isolated fragment opens a group it never closes within the string.","commonSituations":"Truncating LaTeX templates mid-group; string concatenation that drops a closing brace; passing half of a LaTeX command pair as an isolated substring.","solutions":["Close every opened brace in the tex string before constructing MathTex","If isolating substrings, make each isolated fragment internally brace-balanced","Render templates then assert balance (string.count('{') == string.count('}')) before passing to MathTex"],"exampleFix":"# before\nMathTex(r'\\sqrt{2')  # unclosed group -> raises\n\n# after\nMathTex(r'\\sqrt{2}')","handlingStrategy":"validation","validationCode":"assert tex_str.count('{') == tex_str.count('}'), 'unclosed brace group in tex string'","typeGuard":null,"tryCatchPattern":"try:\n    tex = MathTex(s)\nexcept ValueError as e:\n    if \"Missing '}'\" in str(e):\n        s = s + '}' * (s.count('{') - s.count('}'))\n        tex = MathTex(s)","preventionTips":["Keep every isolated substring internally brace-balanced","Validate count('{') == count('}') after any string manipulation","Avoid truncating LaTeX templates mid-group"],"tags":["manim","latex","mathtex","parsing","braces"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}