Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(auth): include error fields in recovery path
Kfir Amar6186babdb338
diff --git a/src/sse/services/auth.ts b/src/sse/services/auth.tsindex 185eb1fd30..c248ab138c 100644--- a/src/sse/services/auth.ts+++ b/src/sse/services/auth.ts@@ -35,6 +35,8 @@ interface ProviderConnectionView {consecutiveUseCount: number;priority: number;lastError: string | null;+ lastErrorType: string | null;+ lastErrorSource: string | null;errorCode: string | number | null;backoffLevel: number;}@@ -76,6 +78,8 @@ function toProviderConnection(value: unknown): ProviderConnectionView {consecutiveUseCount: toNumber(row.consecutiveUseCount, 0),priority: toNumber(row.priority, 999),lastError: toStringOrNull(row.lastError),+ lastErrorType: toStringOrNull(row.lastErrorType),+ lastErrorSource: toStringOrNull(row.lastErrorSource),errorCode:typeof row.errorCode === "string" || typeof row.errorCode === "number" ? row.errorCode : null,backoffLevel: toNumber(row.backoffLevel, 0),@@ -469,6 +473,9 @@ export async function getProviderCredentials(// Include current status for optimization checktestStatus: connection.testStatus,lastError: connection.lastError,+ lastErrorType: connection.lastErrorType,+ lastErrorSource: connection.lastErrorSource,+ errorCode: connection.errorCode,rateLimitedUntil: connection.rateLimitedUntil,};} finally {diff --git a/tests/unit/auth-clear-account-error.test.mjs b/tests/unit/auth-clear-account-error.test.mjsindex 6744d37bd5..cab519edff 100644--- a/tests/unit/auth-clear-account-error.test.mjs+++ b/tests/unit/auth-clear-account-error.test.mjs@@ -41,16 +41,8 @@ test("clearAccountError clears stale provider error metadata after recovery", asbackoffLevel: 2,});- await auth.clearAccountError(created.id, {- ...created,- testStatus: "error",- lastError: "Health check: token refresh failed",- lastErrorType: "token_refresh_failed",- lastErrorSource: "oauth",- errorCode: "refresh_failed",- rateLimitedUntil: new Date(Date.now() + 60_000).toISOString(),- backoffLevel: 2,- });+ const credentials = await auth.getProviderCredentials("codex");+ await auth.clearAccountError(created.id, credentials);const updated = await providersDb.getProviderConnectionById(created.id);assert.equal(updated.testStatus, "active");