decolua/9router · error

All accounts unavailable

Error message

All accounts unavailable

What it means

There were credentials for the provider, but the account-selection loop exhausted them all (excludeConnectionIds non-empty) without finding a usable one. The handler returns lastStatus (or 503) with lastError, defaulting the message to 'All accounts unavailable'.

Source

Thrown at src/sse/handlers/chat.js:243

  let lastError = null;
  let lastStatus = null;

  while (true) {
    const credentials = await getProviderCredentials(provider, excludeConnectionIds, model);

    // All accounts unavailable
    if (!credentials || credentials.allRateLimited) {
      if (credentials?.allRateLimited) {
        const errorMsg = lastError || credentials.lastError || "Unavailable";
        const status = lastStatus || Number(credentials.lastErrorCode) || HTTP_STATUS.SERVICE_UNAVAILABLE;
        log.warn("CHAT", `[${provider}/${model}] ${errorMsg} (${credentials.retryAfterHuman})`);
        return unavailableResponse(status, `[${provider}/${model}] ${errorMsg}`, credentials.retryAfter, credentials.retryAfterHuman);
      }
      if (excludeConnectionIds.size === 0) {
        log.warn("AUTH", `No active credentials for provider: ${provider}`);
        return errorResponse(HTTP_STATUS.NOT_FOUND, `No active credentials for provider: ${provider}`);
      }
      log.warn("CHAT", "No more accounts available", { provider });
      return errorResponse(lastStatus || HTTP_STATUS.SERVICE_UNAVAILABLE, lastError || "All accounts unavailable");
    }

    // Account selection shown in the unified "▶" line (acc:...)
    const refreshedCredentials = await checkAndRefreshToken(provider, credentials);

    // Ensure real project ID is available for providers that need it (P0 fix: cold miss)
    if ((provider === "antigravity" || provider === "gemini-cli") && !refreshedCredentials.projectId) {
      const pid = await getProjectIdForConnection(credentials.connectionId, refreshedCredentials.accessToken, provider);
      if (pid) {
        refreshedCredentials.projectId = pid;
        // Persist to DB in background so subsequent requests have it immediately
        updateProviderCredentials(credentials.connectionId, { projectId: pid }).catch(() => { });
      }
    }

    // Use shared chatCore
    const chatSettings = await getSettings();

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Check the dashboard log for lastError to see why each account failed; fix the root cause per account (re-auth, new key).
  2. Re-authenticate OAuth accounts whose tokens expired/revoked; replace invalid API keys.
  3. Add a healthy provider account or configure combo fallback to other providers.
  4. If an account was marked unavailable, clear its error state (clearAccountError) after fixing credentials and retry.

Example fix

// before
// all provider accounts invalid; client blindly retries the same model
{ "model": "cursor/gpt-4o" }

// after
// fix/re-auth accounts in dashboard, or add fallback combo
{ "model": "my-combo" }  // combo: cursor/gpt-4o, openai/gpt-4o
Defensive patterns

Strategy: fallback

Validate before calling

const creds = await fetch(`${base}/dashboard/api/credentials`).then(r => r.json());
const healthy = creds.filter(c => c.provider === provider && c.active && !c.lastError);
if (healthy.length === 0) throw new Error(`all ${provider} accounts unhealthy; fix or use another provider`);

Type guard

null

Try / catch

const res = await fetch(url, opts);
const text = await res.text();
if (res.status >= 500 && text.includes('All accounts unavailable')) {
  // fail over to another provider/model rather than retrying the same one
  return requestVia(fallbackModel, request);
}

Prevention

When it happens

Trigger: POST /v1/chat/completions where each of the provider's accounts was tried and excluded during this request (auth failures, per-account errors), and after the loop none remain, so the last upstream error/status is returned.

Common situations: Multiple accounts all with expired/invalid API keys; OAuth refresh tokens revoked on every account; per-account upstream errors (quota, suspension) across the whole pool; a combo whose member models map to providers that are all down.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/2c7f9e5f3f9ed24c. Report an issue: GitHub.