opendatalab/MinerU · error · Exception
Unknown process_mode: {process_mode}
Error message
Unknown process_mode: {process_mode} What it means
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.
Source
Thrown at mineru/cli/common.py:286
f_dump_orig_pdf,
f_dump_md,
f_dump_content_list,
f_dump_middle_json,
f_dump_model_output,
f_make_md_mode,
middle_json,
model_output=None,
process_mode="vlm",
):
from mineru.backend.pipeline.pipeline_middle_json_mkcontent import union_make as pipeline_union_make
if process_mode == "pipeline":
make_func = pipeline_union_make
elif process_mode == "vlm":
make_func = vlm_union_make
elif process_mode in office_suffixes:
make_func = office_union_make
else:
raise Exception(f"Unknown process_mode: {process_mode}")
"""处理输出文件"""
if f_draw_layout_bbox:
try:
draw_layout_bbox(pdf_info, pdf_bytes, local_md_dir, f"{pdf_file_name}_layout.pdf")
except Exception as exc:
logger.warning(f"Skipping layout bbox visualization for {pdf_file_name}: {exc}")
if f_draw_span_bbox:
try:
draw_span_bbox(pdf_info, pdf_bytes, local_md_dir, f"{pdf_file_name}_span.pdf")
except Exception as exc:
logger.warning(f"Skipping span bbox visualization for {pdf_file_name}: {exc}")
if f_dump_orig_pdf:
if process_mode in ["pipeline", "vlm"]:
md_writer.write(
f"{pdf_file_name}_origin.pdf",
pdf_bytes,View on GitHub (pinned to 4fe4bde114)
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.
Example fix
# before
_process_output(pdf_info, bytes, name, md_dir, img_dir, middle_json, process_mode=backend) # backend='hybrid' -> raises
# after
if backend not in ('pipeline', 'vlm') and backend not in office_suffixes:
raise ValueError(f"Unsupported backend for markdown generation: {backend}")
_process_output(pdf_info, bytes, name, md_dir, img_dir, middle_json, process_mode=backend) Defensive patterns
Strategy: validation
Validate before calling
from mineru.cli.common import office_suffixes
VALID_PROCESS_MODES = {'pipeline', 'vlm', *office_suffixes}
def assert_process_mode(mode: str) -> None:
if mode not in VALID_PROCESS_MODES:
raise ValueError(f"process_mode must be one of {sorted(VALID_PROCESS_MODES)}, got {mode!r}") Type guard
def is_valid_process_mode(mode: str) -> bool:
return mode in {'pipeline', 'vlm'} or mode in office_suffixes Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Unknown backend type: {backend}
- Invalid backend. Allowed values: {allowed_values}
- Invalid effort. Allowed values: {allowed_values}
- max_concurrent_requests must be a positive integer
- Unsupported office suffix: {file_suffix}
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/72a90d8c2f502ca9.
Report an issue: GitHub.