{"record":{"id":"ec61be3dcb3c2f07","repo":"zeroclaw-labs/zeroclaw","slug":"minimax-oauth-refresh-failed-http-status-det","errorCode":null,"errorMessage":"MiniMax OAuth refresh failed (HTTP {status}): {detail}","messagePattern":"MiniMax OAuth refresh failed \\(HTTP (.+?)\\): (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-providers/src/lib.rs","lineNumber":479,"sourceCode":"                \"minimax: OAuth refresh request failed\"\n            );\n            anyhow::Error::msg(format!(\"MiniMax OAuth refresh request failed: {error}\"))\n        })?;\n\n    let status = response.status();\n    let body = response\n        .text()\n        .unwrap_or_else(|_| \"<failed to read MiniMax OAuth response body>\".to_string());\n    let parsed = serde_json::from_str::<MinimaxOauthRefreshResponse>(&body).ok();\n\n    if !status.is_success() {\n        let detail = parsed\n            .as_ref()\n            .and_then(|payload| payload.base_resp.as_ref())\n            .and_then(|base| base.status_msg.as_deref())\n            .filter(|msg| !msg.trim().is_empty())\n            .unwrap_or(body.as_str());\n        anyhow::bail!(\"MiniMax OAuth refresh failed (HTTP {status}): {detail}\");\n    }\n\n    if let Some(payload) = parsed {\n        if let Some(status_text) = payload.status.as_deref()\n            && !status_text.eq_ignore_ascii_case(\"success\")\n        {\n            let detail = payload\n                .base_resp\n                .as_ref()\n                .and_then(|base| base.status_msg.as_deref())\n                .unwrap_or(status_text);\n            anyhow::bail!(\"MiniMax OAuth refresh failed: {detail}\");\n        }\n        if let Some(token) = payload\n            .access_token\n            .as_deref()\n            .map(str::trim)\n            .filter(|token| !token.is_empty())","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-providers/src/lib.rs#L461-L497","documentation":"refresh_minimax_oauth_access_token exchanges the configured MiniMax oauth_refresh_token for an access token at the region-specific token endpoint. A non-2xx HTTP status fails with the response's base_resp.status_msg text, or the raw body when that field is missing. Called during provider construction, before any chat request.","triggerScenarios":"POST of grant_type=refresh_token returning 400/401 (expired or revoked refresh_token), or 5xx during an upstream incident; response body echoed verbatim when base_resp.status_msg is absent.","commonSituations":"MiniMax refresh tokens expiring after long downtime; token copied with whitespace or truncation into config; region endpoint mismatch routing the refresh to the wrong geography.","solutions":["Obtain a fresh oauth_refresh_token from the MiniMax auth flow and update the profile","Read status_msg in the message — it is the provider's own failure text and names the real cause","For 5xx details, retry after a short wait before assuming credential failure","Verify the configured region so the refresh hits the correct endpoint"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"fn minimax_token_configured(api_key: Option<&str>) -> bool {\n    api_key.map(|k| !k.trim().is_empty()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match refresh_minimax_oauth_access_token(&token, &client_id, region) {\n    Err(e) if e.to_string().contains(\"HTTP 5\") => retry_after(backoff),\n    Err(e) => Err(e.context(\"MiniMax refresh token needs reissue\")), // 4xx: credential problem\n    ok => ok,\n}","preventionTips":["Store the MiniMax oauth_refresh_token in a secret manager and rotate before expiry","Verify the region setting matches where the token was issued","Treat 4xx refresh failures as credential events and 5xx as transient"],"tags":["minimax","oauth","refresh-token","http-status","authentication"],"backgroundTag":"oauth-refresh-token-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}