From f89f92f45a40053ed72e558caa3073957fc5764a Mon Sep 17 00:00:00 2001 From: Dingding-leo <193228693+Dingding-leo@users.noreply.github.com> Date: Mon, 27 Jul 2026 03:07:54 +0930 Subject: [PATCH] fix(open-sse): add 'has been exhausted' to CREDITS_EXHAUSTED_SIGNALS (fixes #8631) Adds 'has been exhausted' string to CREDITS_EXHAUSTED_SIGNALS array so free-tier depletion errors like 'The free tier of the model has been exhausted.' are classified as QUOTA_EXHAUSTED rather than falling through to generic error handling. --- open-sse/services/accountFallback.ts | 1 + tests/unit/error-classifier.test.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/open-sse/services/accountFallback.ts b/open-sse/services/accountFallback.ts index 0f43303e81..97ff711685 100644 --- a/open-sse/services/accountFallback.ts +++ b/open-sse/services/accountFallback.ts @@ -183,6 +183,7 @@ export const CREDITS_EXHAUSTED_SIGNALS = [ "out of credits", "payment required", "free tier of the model has been exhausted", + "has been exhausted", // #5239: providers (e.g. DeepSeek/GLM-style) return "Insufficient account balance" // on a depleted key. 402 is already terminalized by status, but catch non-402 // out-of-credit bodies here too. diff --git a/tests/unit/error-classifier.test.ts b/tests/unit/error-classifier.test.ts index ef9b740955..fac4760cbd 100644 --- a/tests/unit/error-classifier.test.ts +++ b/tests/unit/error-classifier.test.ts @@ -27,6 +27,11 @@ test("classifyProviderError: 400 + billing signal => QUOTA_EXHAUSTED", () => { error: { message: "insufficient_quota: exceeded your current quota" }, }); assert.equal(result, PROVIDER_ERROR_TYPES.QUOTA_EXHAUSTED); + + const resultExhausted = classifyProviderError(400, { + error: { message: "The free tier of the model has been exhausted." }, + }); + assert.equal(resultExhausted, PROVIDER_ERROR_TYPES.QUOTA_EXHAUSTED); }); test("classifyProviderError: 429 without billing signal => RATE_LIMITED", () => { @@ -132,10 +137,6 @@ test("classifyProviderError: 404 => MODEL_NOT_FOUND", () => { }); test("classifyProviderError: 404 with provider => MODEL_NOT_FOUND", () => { - const result = classifyProviderError( - 404, - { error: { message: "Not Found" } }, - "v0-vercel" - ); + const result = classifyProviderError(404, { error: { message: "Not Found" } }, "v0-vercel"); assert.equal(result, PROVIDER_ERROR_TYPES.MODEL_NOT_FOUND); });