{"record":{"id":"b57556b0642f5e98","repo":"opendatalab/MinerU","slug":"unsupported-middle-json-backend-for-client-side-ou","errorCode":null,"errorMessage":"Unsupported middle json backend for client-side output generation: {backend}","messagePattern":"Unsupported middle json backend for client-side output generation: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/cli/client_side_output.py","lineNumber":31,"sourceCode":"SUPPORTED_BACKENDS = {*PDF_BACKENDS, \"office\"}\n\n\ndef _select_union_make(backend: str) -> Callable[[list, str, str], Any]:\n    \"\"\"根据 middle json 后端选择对应的 Markdown/content list 渲染函数。\"\"\"\n    if backend == \"pipeline\":\n        from mineru.backend.pipeline.pipeline_middle_json_mkcontent import union_make\n\n        return union_make\n    if backend in {\"vlm\", \"hybrid\"}:\n        from mineru.backend.vlm.vlm_middle_json_mkcontent import union_make\n\n        return union_make\n    if backend == \"office\":\n        from mineru.backend.office.office_middle_json_mkcontent import union_make\n\n        return union_make\n\n    raise ValueError(\n        f\"Unsupported middle json backend for client-side output generation: {backend}\"\n    )\n\n\ndef _write_json(path: Path, payload: Any) -> None:\n    \"\"\"按项目现有格式写入 JSON 文件，保持中文内容可读。\"\"\"\n    path.write_text(\n        json.dumps(payload, ensure_ascii=False, indent=4),\n        encoding=\"utf-8\",\n    )\n\n\ndef regenerate_client_side_outputs(\n    parse_dir: str | Path,\n    doc_stem: str,\n) -> tuple[Path, ...]:\n    \"\"\"读取服务端 staged/finalized middle json，并在客户端覆盖生成最终输出产物。\"\"\"\n    parse_dir = Path(parse_dir)","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/cli/client_side_output.py#L13-L49","documentation":"ValueError from _select_union_make(): client-side output generation dispatches markdown/content-list rendering by the middle-json's backend tag, and the backend must be one of the supported families (pipeline -> pipeline_middle_json_mkcontent, vlm/hybrid -> vlm module, office -> office module). Anything else cannot be rendered locally.","triggerScenarios":"Calling regenerate_client_side_outputs() (indirectly via client-side output generation after a parse) where the staged {doc}_middle.json has _backend set to an unexpected value such as an old backend name or a hand-edited/custom tag.","commonSituations":"Middle-json files produced by an older mineru version whose _backend tags differ; users editing or post-processing middle.json and changing/removing _backend; mixing outputs from forks that add backend families.","solutions":["Regenerate the middle json with the current mineru version so _backend is one of pipeline/vlm/hybrid/office","If editing middle.json manually, keep _backend intact and valid","Re-download the artifacts from the server instead of reusing stale local staged files","Pin matching versions between the server that produced the json and the client that renders it"],"exampleFix":"# before: stale middle json with \"_backend\": \"vlm-auto-engine\"\n\n# after: regenerate via the server, yielding \"_backend\": \"vlm\"","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"pipeline\", \"vlm\", \"hybrid\", \"office\"}\nbackend = json.loads(middle_json_path.read_text(encoding=\"utf-8\")).get(\"_backend\")\nif backend not in SUPPORTED:\n    raise SystemExit(f\"Cannot render middle json: backend {backend!r} not supported; regenerate artifacts with this mineru version\")","typeGuard":"def is_renderable_middle_json(payload: object) -> bool:\n    return (\n        isinstance(payload, dict)\n        and payload.get(\"_backend\") in {\"pipeline\", \"vlm\", \"hybrid\", \"office\"}\n        and isinstance(payload.get(\"pdf_info\"), list)\n    )","tryCatchPattern":"try:\n    regenerate_client_side_outputs(parse_dir, doc_stem)\nexcept ValueError as e:\n    if \"Unsupported middle json backend\" in str(e):\n        # artifacts are stale — refetch from server instead of rendering locally\n        refetch_results()\n    else:\n        raise","preventionTips":["Keep client and server mineru versions aligned","Never edit _backend in staged middle.json files","Regenerate rather than patch stale local artifacts"],"tags":["client-side","middle-json","backend","rendering"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}