{"record":{"id":"1fd71a160c7339ab","repo":"opendatalab/MinerU","slug":"max-concurrent-requests-must-be-a-positive-integer","errorCode":null,"errorMessage":"max_concurrent_requests must be a positive integer","messagePattern":"max_concurrent_requests must be a positive integer","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/cli/client.py","lineNumber":767,"sourceCode":"async def download_result_zip(\n    client: httpx.AsyncClient,\n    submit_response: SubmitResponse,\n    planned_task: PlannedTask,\n) -> Path:\n    return await _api_client.download_result_zip(\n        client=client,\n        submit_response=submit_response,\n        task_label=format_task_label(planned_task),\n    )\n\n\ndef safe_extract_zip(zip_path: Path, output_dir: Path) -> None:\n    _api_client.safe_extract_zip(zip_path, output_dir)\n\n\ndef resolve_submit_concurrency(max_concurrent_requests: int, task_count: int) -> int:\n    if max_concurrent_requests <= 0:\n        raise ValueError(\"max_concurrent_requests must be a positive integer\")\n    return max(1, min(max_concurrent_requests, task_count))\n\n\ndef resolve_effective_max_concurrent_requests(\n    local_max: int,\n    server_max: int,\n) -> int:\n    return _api_client.resolve_effective_max_concurrent_requests(\n        local_max=local_max,\n        server_max=server_max,\n    )\n\n\nasync def execute_planned_tasks(\n    planned_tasks: list[PlannedTask],\n    concurrency: int,\n    task_runner: Callable[[PlannedTask], Awaitable[None]],\n) -> list[TaskFailure]:","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/cli/client.py#L749-L785","documentation":"ValueError from resolve_submit_concurrency(): max_concurrent_requests must be a positive integer; zero or negative values are rejected because the submit loop would otherwise make no progress (min() is clamped to at least 1, but only after the positivity check).","triggerScenarios":"Invoking the CLI batch submit path with --max-concurrent-requests 0 or a negative number; programmatically passing max_concurrent_requests=0 intending 'auto'.","commonSituations":"Users expecting 0 to mean 'let the tool decide'; CI configs templating an unset variable that expands to 0; arithmetic like n-1 with n=1 yielding 0.","solutions":["Pass a positive integer (e.g. 4 or 8)","Treat 0/'auto' in your wrapper by substituting a sensible default before calling mineru","Guard against empty-string env vars that int() to exceptions or default to 0"],"exampleFix":"# before\nconcurrency = resolve_submit_concurrency(max_concurrent_requests=0, task_count=10)\n\n# after\nconcurrency = resolve_submit_concurrency(max_concurrent_requests=4, task_count=10)","handlingStrategy":"validation","validationCode":"if not isinstance(max_concurrent_requests, int) or isinstance(max_concurrent_requests, bool) or max_concurrent_requests <= 0:\n    max_concurrent_requests = 4  # sane default instead of failing at submit time","typeGuard":"def is_positive_int(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v > 0","tryCatchPattern":null,"preventionTips":["Treat 0/empty env values as 'use default (4)' in wrappers","Validate numeric CLI flags immediately after parsing","Never compute concurrency as n-1 without clamping to >= 1"],"tags":["cli","concurrency","validation"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}