opendatalab/MinerU · error · Exception

ak, sk or endpoint not found in {CONFIG_FILE_NAME}

Error message

ak, sk or endpoint not found in {CONFIG_FILE_NAME}

What it means

Raised when MineRU resolves S3/object-storage credentials for a bucket and one of access_key, secret_key, or storage_endpoint is None in the config file (mineru.json, overridable via MINERU_TOOLS_CONFIG_JSON; older setups used magic-pdf.json). The config's bucket_info maps bucket names to (ak, sk, endpoint) triples, falling back to the '[default]' entry when the bucket is not listed. If any element of the selected triple is explicitly null (or the triple unpacks to None values), this exception fires — a missing file would fail earlier in read_config instead.

Source

Thrown at mineru/utils/config_reader.py:74

    logger.warning(
        f"Unsupported 'model-source' in {CONFIG_FILE_NAME}: {model_source}, use {default} as default"
    )
    return default


def get_s3_config(bucket_name: str):
    """~/magic-pdf.json 读出来."""
    config = read_config()

    bucket_info = config.get('bucket_info')
    if bucket_name not in bucket_info:
        access_key, secret_key, storage_endpoint = bucket_info['[default]']
    else:
        access_key, secret_key, storage_endpoint = bucket_info[bucket_name]

    if access_key is None or secret_key is None or storage_endpoint is None:
        raise Exception(f'ak, sk or endpoint not found in {CONFIG_FILE_NAME}')

    # logger.info(f"get_s3_config: ak={access_key}, sk={secret_key}, endpoint={storage_endpoint}")

    return access_key, secret_key, storage_endpoint


def get_s3_config_dict(path: str):
    access_key, secret_key, storage_endpoint = get_s3_config(get_bucket_name(path))
    return {'ak': access_key, 'sk': secret_key, 'endpoint': storage_endpoint}


def get_bucket_name(path):
    bucket, key = parse_bucket_key(path)
    return bucket


def parse_bucket_key(s3_full_path: str):
    """

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Open the config file (default ~/mineru.json, or the path in MINERU_TOOLS_CONFIG_JSON) and fill bucket_info['[default]'] with real values: ["<access_key>", "<secret_key>", "<endpoint_url>"] — all three must be non-null strings.
  2. If using a specific bucket, add a matching key (the bucket name) under bucket_info with its own triple, or rely on '[default]'.
  3. Confirm the config file MineRU actually reads: run with MINERU_TOOLS_CONFIG_JSON unset unless you intentionally override it; check for a stale magic-pdf.json left from older versions.
  4. Validate the JSON parses and the triple has exactly 3 elements — mis-ordered or 2-element triples also produce None unpacking errors.

Example fix

// before
"bucket_info": {
  "[default]": [null, null, null]
}

// after
"bucket_info": {
  "[default]": ["AKIDxxxx", "secretxxxx", "https://your-bucket.oss-cn-beijing.aliyuncs.com"]
}
Defensive patterns

Strategy: validation

Validate before calling

import json, os
def s3_config_ready() -> bool:
    path = os.path.expanduser(os.getenv('MINERU_TOOLS_CONFIG_JSON', '~/mineru.json'))
    try:
        cfg = json.load(open(path))
    except Exception:
        return False
    triple = cfg.get('bucket_info', {}).get('[default]')
    return bool(triple) and all(isinstance(v, str) and v for v in triple)

Type guard

def is_valid_bucket_triple(v) -> bool:
    return (
        isinstance(v, (list, tuple)) and len(v) == 3
        and all(isinstance(x, str) and x for x in v)
    )

Try / catch

try:
    ak, sk, endpoint = get_s3_config(bucket)
except Exception as e:
    if 'ak, sk or endpoint not found' in str(e):
        fail_fast('Object-storage credentials missing in mineru.json bucket_info')
    raise

Prevention

When it happens

Trigger: Calling get_s3_config(bucket) / get_s3_config_dict(path) when the bucket_info entry for the bucket (or '[default]') contains null values, e.g. {"bucket_info": {"[default]": [null, null, null]}}. Any MineRU flow that reads models or files from S3-style storage hits this on first credential lookup.

Common situations: A config generated from a template where bucket_info was never filled in (nulls left in place); a migration from magic-pdf.json to mineru.json that copied an incomplete section; a CI environment pointing MINERU_TOOLS_CONFIG_JSON at a stub config; mixing up the [default] triple order or pasting placeholder strings like 'ak' and leaving endpoint null.

Related errors


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