{"record":{"id":"1094cc085e3e6414","repo":"chatboxai/chatbox","slug":"token-refresh-failed-payload-base-resp-status","errorCode":null,"errorMessage":"Token refresh failed: ${payload.base_resp?.status_msg || text}","messagePattern":"Token refresh failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/oauth/providers/minimax.ts","lineNumber":229,"sourceCode":"        }).toString(),\n      })\n\n      const text = await response.text()\n      if (!response.ok) {\n        log.error(`[OAuth:${config.name}] Token refresh failed:`, text)\n        throw new Error(`Token refresh failed: ${text}`)\n      }\n\n      const payload = JSON.parse(text || '{}') as {\n        status?: string\n        access_token?: string\n        refresh_token?: string\n        expired_in?: number\n        base_resp?: { status_msg?: string }\n      }\n\n      if (payload.status !== 'success' || !payload.access_token) {\n        throw new Error(`Token refresh failed: ${payload.base_resp?.status_msg || text}`)\n      }\n\n      return {\n        accessToken: payload.access_token,\n        refreshToken: payload.refresh_token || credentials.refreshToken,\n        expiresAt: toExpiresAt(payload.expired_in),\n      }\n    },\n  }\n\n  return provider\n}\n\nexport const minimaxOAuthProvider = createMiniMaxOAuthProvider({\n  providerId: 'minimax',\n  name: 'MiniMax Global',\n  baseUrl: 'https://api.minimax.io',\n})","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/main/oauth/providers/minimax.ts#L211-L247","documentation":"Thrown by MiniMax's refreshToken() when the HTTP response was 2xx but payload.status !== 'success' or payload.access_token is missing. MiniMax returns 200 with a business status field, so this guard catches application-level refresh failures that the HTTP check missed. The message prefers base_resp.status_msg (human-readable MiniMax reason) and falls back to the raw text.","triggerScenarios":"MiniMax returns 200 with status='fail' or a non-zero base_resp.status_code; access_token field absent despite 200; response shape changed and status field is now named differently; refresh token was accepted at transport but rejected at business layer (e.g. quota, account suspended).","commonSituations":"MiniMax API contract drift (status field renamed); account throttled or suspended returning 200 with an error status_msg; partial response from a load balancer.","solutions":["Read base_resp.status_msg — it carries MiniMax's specific reason; treat account/quota messages as requiring re-auth or user action.","If the response shape changed (status renamed), update the parse to match the current MiniMax contract.","On business-level 'fail', clear stored credentials and prompt an interactive login rather than retrying the same refresh token."],"exampleFix":"// before\nif (payload.status !== 'success' || !payload.access_token) {\n  throw new Error(`Token refresh failed: ${payload.base_resp?.status_msg || text}`)\n}\n\n// after\nif (payload.status !== 'success' || !payload.access_token) {\n  const reason = payload.base_resp?.status_msg || text\n  log.error('[OAuth:MiniMax] business refresh failure', reason)\n  if (/invalid|expired|revok/i.test(reason)) throw new ReauthRequiredError(reason)\n  throw new Error(`Token refresh failed: ${reason}`)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isMiniMaxBusinessFailure(body: unknown): body is { status: string; base_resp?: { status_msg?: string } } {\n  return typeof body === 'object' && body !== null && (body as any).status !== 'success'\n}","tryCatchPattern":"try {\n  return await provider.refreshToken(credentials)\n} catch (e) {\n  const msg = String(e)\n  if (/invalid|expired|revok|suspend|quota/i.test(msg)) {\n  await clearStoredCredentials()\n  throw new ReauthRequiredError(msg)\n  }\n  // contract drift: log and surface, do not retry blindly\n  log.error('MiniMax business refresh failure', msg)\n  throw e\n}","preventionTips":["Log the parsed payload when status !== 'success' to detect MiniMax contract drift early.","Treat account-level failures (quota, suspended) as needing user action, not retry.","On contract drift, update the response type/parser rather than dropping the guard."],"tags":["oauth","minimax","refresh-token","application-error"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}