{"record":{"id":"72a90d8c2f502ca9","repo":"opendatalab/MinerU","slug":"unknown-process-mode-process-mode","errorCode":null,"errorMessage":"Unknown process_mode: {process_mode}","messagePattern":"Unknown process_mode: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mineru/cli/common.py","lineNumber":286,"sourceCode":"        f_dump_orig_pdf,\n        f_dump_md,\n        f_dump_content_list,\n        f_dump_middle_json,\n        f_dump_model_output,\n        f_make_md_mode,\n        middle_json,\n        model_output=None,\n        process_mode=\"vlm\",\n):\n    from mineru.backend.pipeline.pipeline_middle_json_mkcontent import union_make as pipeline_union_make\n    if process_mode == \"pipeline\":\n        make_func = pipeline_union_make\n    elif process_mode == \"vlm\":\n        make_func = vlm_union_make\n    elif process_mode in office_suffixes:\n        make_func = office_union_make\n    else:\n        raise Exception(f\"Unknown process_mode: {process_mode}\")\n    \"\"\"处理输出文件\"\"\"\n    if f_draw_layout_bbox:\n        try:\n            draw_layout_bbox(pdf_info, pdf_bytes, local_md_dir, f\"{pdf_file_name}_layout.pdf\")\n        except Exception as exc:\n            logger.warning(f\"Skipping layout bbox visualization for {pdf_file_name}: {exc}\")\n\n    if f_draw_span_bbox:\n        try:\n            draw_span_bbox(pdf_info, pdf_bytes, local_md_dir, f\"{pdf_file_name}_span.pdf\")\n        except Exception as exc:\n            logger.warning(f\"Skipping span bbox visualization for {pdf_file_name}: {exc}\")\n\n    if f_dump_orig_pdf:\n        if process_mode in [\"pipeline\", \"vlm\"]:\n            md_writer.write(\n                f\"{pdf_file_name}_origin.pdf\",\n                pdf_bytes,","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/cli/common.py#L268-L304","documentation":"Raised by _process_output in mineru/cli/common.py when selecting the markdown 'union_make' function: the process_mode argument matched none of the accepted values. Accepted values are the literal strings 'pipeline' and 'vlm', plus any office suffix ('docx', 'pptx', 'xlsx') from mineru.cli.common.office_suffixes. This is an internal dispatch error, not a user-input error, so it indicates a caller bug or a new backend name that this function was never taught.","triggerScenarios":"Calling _process_output (or a higher-level CLI path that forwards a backend/process_mode string into it) with process_mode='hybrid', 'txt', 'auto', or any typo like 'VLM' (case-sensitive). Any newly added backend name that is not one of pipeline/vlm/docx/pptx/xlsx hits the else branch.","commonSituations":"Upgrading mineru to a version that adds a new backend (e.g. hybrid) while an older code path still does the dispatch; passing a user-supplied --backend string straight through without validation; mixing up the values of backend (pipeline/vlm/hybrid) and process_mode (pipeline/vlm/office suffix).","solutions":["Check the exact value being passed for process_mode at the call site; it must be exactly 'pipeline', 'vlm', or one of docx/pptx/xlsx.","If you intended the office path, pass the file suffix ('docx'/'pptx'/'xlsx') as process_mode, not 'office'.","If you are using a 'hybrid' or other new backend, update to a mineru version where _process_output handles it, or route around this helper for that backend.","Add an explicit whitelist check before calling so an invalid mode fails with your own clearer error."],"exampleFix":"# before\n_process_output(pdf_info, bytes, name, md_dir, img_dir, middle_json, process_mode=backend)  # backend='hybrid' -> raises\n\n# after\nif backend not in ('pipeline', 'vlm') and backend not in office_suffixes:\n    raise ValueError(f\"Unsupported backend for markdown generation: {backend}\")\n_process_output(pdf_info, bytes, name, md_dir, img_dir, middle_json, process_mode=backend)","handlingStrategy":"validation","validationCode":"from mineru.cli.common import office_suffixes\nVALID_PROCESS_MODES = {'pipeline', 'vlm', *office_suffixes}\n\ndef assert_process_mode(mode: str) -> None:\n    if mode not in VALID_PROCESS_MODES:\n        raise ValueError(f\"process_mode must be one of {sorted(VALID_PROCESS_MODES)}, got {mode!r}\")","typeGuard":"def is_valid_process_mode(mode: str) -> bool:\n    return mode in {'pipeline', 'vlm'} or mode in office_suffixes","tryCatchPattern":null,"preventionTips":["Validate backend/process_mode strings at your API/CLI boundary against a published enum instead of letting them flow into internal dispatch.","Add unit tests asserting every backend name your app exposes maps to an accepted process_mode.","Treat 'Unknown process_mode' as a programming bug: fail loudly in dev, never silently default."],"tags":["mineru","backend-selection","validation","cli"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}