tirth8205/code-review-graph · error · RuntimeError

MiniMax API error: {base_resp.get('status_msg', 'unknown')}

Error message

MiniMax API error: {base_resp.get('status_msg', 'unknown')}

What it means

This RuntimeError is raised when the MiniMax embedding API returns a non-zero `base_resp.status_code` in an otherwise successful HTTP response — i.e. the application-level payload reports an error (auth failure, bad input, quota, invalid model). The message surfaces the server's `status_msg` or 'unknown' if absent.

Source

Thrown at code_review_graph/embeddings.py:319

            headers={
                "Content-Type": "application/json",
                "Authorization": f"Bearer {self._api_key}",
                "User-Agent": _USER_AGENT,
                "Accept": "application/json",
            },
        )

        max_retries = 3
        for attempt in range(max_retries):
            try:
                import ssl
                _ssl_ctx = ssl.create_default_context()
                with urllib.request.urlopen(req, timeout=60, context=_ssl_ctx) as resp:  # nosec B310
                    body = _json.loads(resp.read().decode("utf-8"))

                base_resp = body.get("base_resp", {})
                if base_resp.get("status_code", 0) != 0:
                    raise RuntimeError(
                        f"MiniMax API error: {base_resp.get('status_msg', 'unknown')}"
                    )

                return body["vectors"]
            except Exception as e:
                err_str = str(e)
                is_retryable = "429" in err_str or "500" in err_str or "503" in err_str
                if not is_retryable or attempt == max_retries - 1:
                    raise
                wait = 2 ** attempt
                logger.warning(
                    "MiniMax API error (attempt %d/%d), retrying in %ds: %s",
                    attempt + 1, max_retries, wait, e,
                )
                time.sleep(wait)

        return []  # unreachable, but keeps mypy happy

View on GitHub (pinned to b58668751a)

Solutions

  1. Inspect status_msg in the raised message to identify the exact server-side cause (auth vs quota vs input)
  2. Verify the MiniMax API key environment/credentials are current and valid
  3. Check the model name and reduce batch size / text length to meet MiniMax limits
  4. Add retry with backoff if the status indicates transient throttling
Defensive patterns

Strategy: retry

Validate before calling

# Pre-flight: confirm credentials are configured before batching
import os
assert os.environ.get("MINIMAX_API_KEY"), "MINIMAX_API_KEY missing"
assert 0 < len(texts) <= 100, "MiniMax batch must be 1..100 items"

Try / catch

import time
for attempt in range(3):
    try:
        vecs = provider.embed(texts)
        break
    except RuntimeError as e:
        msg = str(e)
        if "MiniMax API error" in msg and any(k in msg for k in ("rate", "limit", "throttl")):
            time.sleep(2 ** attempt)
            continue
        raise

Prevention

When it happens

Trigger: POSTing an embeddings batch to the MiniMax API (embed() or embed_query()) where the response body's base_resp.status_code != 0: expired/invalid API key, model name typo, text exceeding limits, or rate/quota exhaustion.

Common situations: Rotated or expired MiniMax API keys in CI, using a model identifier not enabled for the account, or oversized batches (batch_size is capped at 100 in embed).

Related errors


AI-assisted analysis of tirth8205/code-review-graph@b58668751a (2026-08-28). Data as JSON: /api/errors/b95bb4100015a7da. Report an issue: GitHub.