{"record":{"id":"a882ce2a60256354","repo":"opendatalab/MinerU","slug":"ak-sk-or-endpoint-not-found-in-config-file-name","errorCode":null,"errorMessage":"ak, sk or endpoint not found in {CONFIG_FILE_NAME}","messagePattern":"ak, sk or endpoint not found in (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mineru/utils/config_reader.py","lineNumber":74,"sourceCode":"\n    logger.warning(\n        f\"Unsupported 'model-source' in {CONFIG_FILE_NAME}: {model_source}, use {default} as default\"\n    )\n    return default\n\n\ndef get_s3_config(bucket_name: str):\n    \"\"\"~/magic-pdf.json 读出来.\"\"\"\n    config = read_config()\n\n    bucket_info = config.get('bucket_info')\n    if bucket_name not in bucket_info:\n        access_key, secret_key, storage_endpoint = bucket_info['[default]']\n    else:\n        access_key, secret_key, storage_endpoint = bucket_info[bucket_name]\n\n    if access_key is None or secret_key is None or storage_endpoint is None:\n        raise Exception(f'ak, sk or endpoint not found in {CONFIG_FILE_NAME}')\n\n    # logger.info(f\"get_s3_config: ak={access_key}, sk={secret_key}, endpoint={storage_endpoint}\")\n\n    return access_key, secret_key, storage_endpoint\n\n\ndef get_s3_config_dict(path: str):\n    access_key, secret_key, storage_endpoint = get_s3_config(get_bucket_name(path))\n    return {'ak': access_key, 'sk': secret_key, 'endpoint': storage_endpoint}\n\n\ndef get_bucket_name(path):\n    bucket, key = parse_bucket_key(path)\n    return bucket\n\n\ndef parse_bucket_key(s3_full_path: str):\n    \"\"\"","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/utils/config_reader.py#L56-L92","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","If using a specific bucket, add a matching key (the bucket name) under bucket_info with its own triple, or rely on '[default]'.","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.","Validate the JSON parses and the triple has exactly 3 elements — mis-ordered or 2-element triples also produce None unpacking errors."],"exampleFix":"// before\n\"bucket_info\": {\n  \"[default]\": [null, null, null]\n}\n\n// after\n\"bucket_info\": {\n  \"[default]\": [\"AKIDxxxx\", \"secretxxxx\", \"https://your-bucket.oss-cn-beijing.aliyuncs.com\"]\n}","handlingStrategy":"validation","validationCode":"import json, os\ndef s3_config_ready() -> bool:\n    path = os.path.expanduser(os.getenv('MINERU_TOOLS_CONFIG_JSON', '~/mineru.json'))\n    try:\n        cfg = json.load(open(path))\n    except Exception:\n        return False\n    triple = cfg.get('bucket_info', {}).get('[default]')\n    return bool(triple) and all(isinstance(v, str) and v for v in triple)","typeGuard":"def is_valid_bucket_triple(v) -> bool:\n    return (\n        isinstance(v, (list, tuple)) and len(v) == 3\n        and all(isinstance(x, str) and x for x in v)\n    )","tryCatchPattern":"try:\n    ak, sk, endpoint = get_s3_config(bucket)\nexcept Exception as e:\n    if 'ak, sk or endpoint not found' in str(e):\n        fail_fast('Object-storage credentials missing in mineru.json bucket_info')\n    raise","preventionTips":["Add a startup preflight check that loads the config and asserts bucket_info['[default]'] has three non-empty strings.","Generate configs from a validated template; treat null placeholders in bucket_info as a deploy-blocking lint error.","Never log the resolved keys — log only that they are present/absent."],"tags":["config","s3","credentials","mineru"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}