zeroclaw-labs/zeroclaw · error · anyhow::Error

MiniMax OAuth refresh response missing access_token

Error message

MiniMax OAuth refresh response missing access_token

What it means

The MiniMax refresh response was HTTP 2xx, JSON-parseable, and reported a success status (or had none), but contained no non-empty access_token string. With nothing to authenticate subsequent requests, refresh fails. This is the terminal fallback of refresh_minimax_oauth_access_token after the status and error paths pass.

Source

Thrown at crates/zeroclaw-providers/src/lib.rs:502

            && !status_text.eq_ignore_ascii_case("success")
        {
            let detail = payload
                .base_resp
                .as_ref()
                .and_then(|base| base.status_msg.as_deref())
                .unwrap_or(status_text);
            anyhow::bail!("MiniMax OAuth refresh failed: {detail}");
        }
        if let Some(token) = payload
            .access_token
            .as_deref()
            .map(str::trim)
            .filter(|token| !token.is_empty())
        {
            return Ok(token.to_string());
        }
    }
    anyhow::bail!("MiniMax OAuth refresh response missing access_token")
}

fn resolve_qwen_oauth_context(credential_override: Option<&str>) -> QwenOauthProviderContext {
    let override_value = credential_override
        .map(str::trim)
        .filter(|value| !value.is_empty());
    let placeholder_requested = override_value
        .map(|value| value.eq_ignore_ascii_case(QWEN_OAUTH_PLACEHOLDER))
        .unwrap_or(false);

    if let Some(explicit) = override_value
        && !placeholder_requested
    {
        return QwenOauthProviderContext {
            credential: Some(explicit.to_string()),
            base_url: None,
        };
    }

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Capture the raw refresh response (proxy or debug logging) and compare it with the documented MiniMax token response
  2. If the field was renamed upstream, upgrade ZeroClaw or file an issue with the observed payload shape
  3. Retry once to rule out a truncated response from an intermediary
  4. Reissue the refresh token if the account state is suspected corrupt
Defensive patterns

Strategy: try-catch

Try / catch

match refresh_minimax_oauth_access_token(&token, &client_id, region) {
    Err(e) if e.to_string().ends_with("missing access_token") => {
        // contract change or truncated body: log the raw exchange once, then fail loudly
        log::error!("MiniMax token response shape changed: {e}");
        Err(e)
    }
    other => other,
}

Prevention

When it happens

Trigger: Response body like `{"status":"success"}` with the access_token field missing, null, or whitespace-only; an HTML or empty body that still parsed as all-optional fields (every field of MinimaxOauthRefreshResponse is optional).

Common situations: Upstream API contract change renaming the token field; gateway or proxy stripping the response body; endpoints returning an unexpected envelope shape after a MiniMax API revision.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/e3f63591c84dec0b. Report an issue: GitHub.