fix: narrow rate-limit pattern to avoid billing misclassification

This commit is contained in:
周鹤0668001310
2026-03-05 09:42:49 +08:00
committed by Altay
parent 152d1e6ca5
commit effd037c89

View File

@@ -535,6 +535,8 @@ describe("classifyFailoverReason", () => {
).toBe("rate_limit");
expect(classifyFailoverReason("all credentials for model x are cooling down")).toBeNull();
expect(classifyFailoverReason("invalid request format")).toBe("format");
expect(classifyFailoverReason("credit balance too low")).toBe("billing");
// Billing with "limit exhausted" must stay billing, not rate_limit (avoids key-disable regression)
expect(
classifyFailoverReason("HTTP 402 payment required. Your limit exhausted for this plan."),
).toBe("billing");
@@ -593,6 +595,7 @@ describe("classifyFailoverReason", () => {
"LLM error 1310: Weekly/Monthly Limit Exhausted. Your limit will reset at 2026-03-06 22:19:54 (request_id: 20260303141547610b7f574d1b44cb)",
),
).toBe("rate_limit");
// Independent coverage for /weekly\/monthly limit/i (no generic "limit exhausted")
expect(classifyFailoverReason("LLM error: weekly/monthly limit reached")).toBe("rate_limit");
});
it("classifies permanent auth errors as auth_permanent", () => {