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

  1. Set the variable to a plain positive integer string: export MINERU_API_MAX_CONCURRENT_REQUESTS=4.
  2. If you want the default behavior, unset the variable entirely (unset MINERU_API_MAX_CONCURRENT_REQUESTS) rather than setting it to an empty string.
  3. Check for stray whitespace/quotes in .env files, docker-compose environment blocks, and Kubernetes manifests — the value must be an exact integer literal.
  4. 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

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


AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14). Data as JSON: /api/errors/0faf3e5ed953256e. Report an issue: GitHub.