opendatalab/MinerU · error · ValueError
Invalid MINERU_API_MAX_CONCURRENT_REQUESTS value: {value}. E
Error message
Invalid MINERU_API_MAX_CONCURRENT_REQUESTS value: {value}. Expected a positive integer. What it means
Raised by MineRU's get_max_concurrent_requests() when the environment variable MINERU_API_MAX_CONCURRENT_REQUESTS is set to a string that int() cannot parse (e.g. 'three', '2.5', '' or '2,'). The default (3) is only used when the variable is unset; any set-but-malformed value is treated as a configuration error rather than silently ignored.
Source
Thrown at mineru/utils/config_reader.py:183
logger.warning(
f"Invalid MINERU_PROCESSING_WINDOW_SIZE value: {value}, use default {default}"
)
return default
return max(1, window_size)
def get_max_concurrent_requests(default: int = 3) -> int:
if default <= 0:
raise ValueError(
f"default max_concurrent_requests must be a positive integer, got {default}"
)
value = os.getenv('MINERU_API_MAX_CONCURRENT_REQUESTS')
if value is None:
return default
try:
max_concurrent_requests = int(value)
except ValueError as exc:
raise ValueError(
"Invalid MINERU_API_MAX_CONCURRENT_REQUESTS value: "
f"{value}. Expected a positive integer."
) from exc
if max_concurrent_requests <= 0:
raise ValueError(
"Invalid MINERU_API_MAX_CONCURRENT_REQUESTS value: "
f"{value}. Expected a positive integer."
)
return max_concurrent_requests
def get_latex_delimiter_config():
config = read_config()
if config is None:
return None
latex_delimiter_config = config.get('latex-delimiter-config', None)
if latex_delimiter_config is None:
# logger.warning(f"'latex-delimiter-config' not found in {CONFIG_FILE_NAME}, use 'None' as default")View on GitHub (pinned to 4fe4bde114)
Solutions
- Set the variable to a plain positive integer string: export MINERU_API_MAX_CONCURRENT_REQUESTS=4.
- If you want the default behavior, unset the variable entirely (unset MINERU_API_MAX_CONCURRENT_REQUESTS) rather than setting it to an empty string.
- Check for stray whitespace/quotes in .env files, docker-compose environment blocks, and Kubernetes manifests — the value must be an exact integer literal.
- Avoid decimals ('2.0') and thousands separators; the parser is strict int(), not float().
Example fix
# before export MINERU_API_MAX_CONCURRENT_REQUESTS="4 " # or =2.5, =four # after export MINERU_API_MAX_CONCURRENT_REQUESTS=4
Defensive patterns
Strategy: validation
Validate before calling
import os
raw = os.getenv('MINERU_API_MAX_CONCURRENT_REQUESTS')
if raw is not None:
try:
n = int(raw)
assert n > 0
except (ValueError, AssertionError):
raise SystemExit(f'MINERU_API_MAX_CONCURRENT_REQUESTS={raw!r} must be a positive integer') Type guard
def valid_concurrency_env(raw: str | None) -> bool:
if raw is None:
return True
try:
return int(raw) > 0
except ValueError:
return False Try / catch
try:
limit = get_max_concurrent_requests(default=3)
except ValueError as e:
raise SystemExit(f'Bad concurrency config: {e}') from e # fail fast at boot, not per request Prevention
- Validate all MINERU_* integer env vars in a single boot-time preflight.
- Prefer unsetting the variable over setting an empty string when defaults are wanted.
- In compose/Kubernetes manifests quote env values and lint them as integers in CI.
When it happens
Trigger: Exporting MINERU_API_MAX_CONCURRENT_REQUESTS with a non-integer value (export MINERU_API_MAX_CONCURRENT_REQUESTS=2.5, =three, or an empty/whitespace string) and then invoking any MineRU API-client code path that calls get_max_concurrent_requests().
Common situations: Quotes or spaces left in a value set in .bashrc/.env/docker-compose; a value copied from documentation that includes units or decimals; CI secrets injecting an empty string for the variable; YAML unquoted '2.5' parsed as a float and stringified.
Related errors
- {MODEL_SOURCE_ENV_VAR}=auto is not supported. Unset {MODEL_S
- ak, sk or endpoint not found in {CONFIG_FILE_NAME}
- model source auto is only supported for internal default det
- Local path for repo_mode '{repo_mode}' is not configured.
- local_max and server_max must both be positive integers
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/0faf3e5ed953256e.
Report an issue: GitHub.