{"record":{"id":"b634de8e71c0181a","repo":"opendatalab/MinerU","slug":"unsupported-formula-label-label","errorCode":null,"errorMessage":"Unsupported formula label: {label}","messagePattern":"Unsupported formula label: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/layout/pp_doclayoutv2.py","lineNumber":1197,"sourceCode":"            or PPDocLayoutV2LayoutModel._is_inline_formula_box(box)\n        )\n\n    @staticmethod\n    def _is_formula_number_box(box: Dict) -> bool:\n        return box.get(\"label\") == \"formula_number\" or int(box.get(\"cls_id\", -1)) == 11\n\n    @staticmethod\n    def _set_box_label(box: Dict, label: str) -> None:\n        \"\"\"统一同步设置 layout 检测框的标签名和类别编号。\"\"\"\n        if label not in PP_DOCLAYOUT_V2_LABEL_TO_ID:\n            raise ValueError(f\"Unsupported PP-DocLayoutV2 label: {label}\")\n        box[\"label\"] = label\n        box[\"cls_id\"] = PP_DOCLAYOUT_V2_LABEL_TO_ID[label]\n\n    @staticmethod\n    def _set_formula_label(box: Dict, label: str) -> None:\n        if label not in {\"inline_formula\", \"display_formula\"}:\n            raise ValueError(f\"Unsupported formula label: {label}\")\n        PPDocLayoutV2LayoutModel._set_box_label(box, label)\n\n    @staticmethod\n    def _set_header_footer_label(box: Dict, label: str) -> None:\n        \"\"\"同步设置页眉/页脚相关标签及其类别编号。\"\"\"\n        if label not in {\"footer\", \"footer_image\", \"header\", \"header_image\"}:\n            raise ValueError(f\"Unsupported header/footer label: {label}\")\n        PPDocLayoutV2LayoutModel._set_box_label(box, label)\n\n    @staticmethod\n    def _set_footnote_label(box: Dict) -> None:\n        \"\"\"同步设置 page footnote 标签及其类别编号。\"\"\"\n        PPDocLayoutV2LayoutModel._set_box_label(box, \"footnote\")\n\n    @classmethod\n    def _reclassify_header_footer_by_page_half(\n        cls,\n        boxes: List[Dict],","sourceCodeStart":1179,"sourceCodeEnd":1215,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/layout/pp_doclayoutv2.py#L1179-L1215","documentation":"ValueError raised by _set_formula_label when label is not exactly 'inline_formula' or 'display_formula'. This narrow helper exists to re-classify detected boxes between the two formula classes (cls_id 15 and 5) and delegates to _set_box_label, so it intentionally accepts only that pair.","triggerScenarios":"_set_formula_label(box, 'formula') or _set_formula_label(box, 'formula_number') — the latter is a different class handled by _is_formula_number_box/cls_id 11, not this helper.","commonSituations":"Post-processing that collapses all math-like labels into 'formula'; passing the formula-number label through the wrong helper when re-classifying adjacent boxes near display formulas.","solutions":["Pass 'inline_formula' or 'display_formula'.","Use _set_box_label(box, 'formula_number') for formula-number boxes instead.","Route other labels through _set_box_label, which accepts all 25 class names."],"exampleFix":"# before\n_set_formula_label(box, 'formula')  # ValueError\n\n# after\n_set_formula_label(box, 'display_formula')\n# or for numbering boxes:\n_set_box_label(box, 'formula_number')","handlingStrategy":"validation","validationCode":"FORMULA_LABELS = {'inline_formula', 'display_formula'}\n\ndef set_formula_label(box: dict, label: str) -> None:\n    if label not in FORMULA_LABELS:\n        raise ValueError(f'formula label must be one of {sorted(FORMULA_LABELS)}, got {label!r}')\n    PPDocLayoutV2LayoutModel._set_formula_label(box, label)","typeGuard":"def is_formula_label(label: str) -> bool:\n    return label in {'inline_formula', 'display_formula'}","tryCatchPattern":null,"preventionTips":["Restrict this helper to exactly 'inline_formula' / 'display_formula'.","Use _set_box_label(box, 'formula_number') for formula-numbering boxes.","Route all other labels through _set_box_label, not the formula helper."],"tags":["layout-model","labels","validation","formula"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}