mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 03:20:23 +00:00
fix: recognize Venice 402 billing errors for model fallback (#43205)
Merged via squash.
Prepared head SHA: 1f6b10b9d9
Co-authored-by: Squabble9 <194720422+Squabble9@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -106,6 +106,9 @@ describe("isBillingErrorMessage", () => {
|
||||
"Payment Required",
|
||||
"HTTP 402 Payment Required",
|
||||
"plans & billing",
|
||||
// Venice returns "Insufficient USD or Diem balance" which has extra words
|
||||
// between "insufficient" and "balance"
|
||||
"Insufficient USD or Diem balance to complete request. Visit https://venice.ai/settings/api to add credits.",
|
||||
];
|
||||
for (const sample of samples) {
|
||||
expect(isBillingErrorMessage(sample)).toBe(true);
|
||||
@@ -149,6 +152,11 @@ describe("isBillingErrorMessage", () => {
|
||||
expect(longResponse.length).toBeGreaterThan(512);
|
||||
expect(isBillingErrorMessage(longResponse)).toBe(false);
|
||||
});
|
||||
it("does not false-positive on short non-billing text that mentions insufficient and balance", () => {
|
||||
const sample = "The evidence is insufficient to reconcile the final balance after compaction.";
|
||||
expect(isBillingErrorMessage(sample)).toBe(false);
|
||||
expect(classifyFailoverReason(sample)).toBeNull();
|
||||
});
|
||||
it("still matches explicit 402 markers in long payloads", () => {
|
||||
const longStructuredError =
|
||||
'{"error":{"code":402,"message":"payment required","details":"' + "x".repeat(700) + '"}}';
|
||||
@@ -650,6 +658,12 @@ describe("classifyFailoverReason", () => {
|
||||
expect(classifyFailoverReason(TOGETHER_ENGINE_OVERLOADED_MESSAGE)).toBe("overloaded");
|
||||
expect(classifyFailoverReason(GROQ_TOO_MANY_REQUESTS_MESSAGE)).toBe("rate_limit");
|
||||
expect(classifyFailoverReason(GROQ_SERVICE_UNAVAILABLE_MESSAGE)).toBe("overloaded");
|
||||
// Venice 402 billing error with extra words between "insufficient" and "balance"
|
||||
expect(
|
||||
classifyFailoverReason(
|
||||
"Insufficient USD or Diem balance to complete request. Visit https://venice.ai/settings/api to add credits.",
|
||||
),
|
||||
).toBe("billing");
|
||||
});
|
||||
|
||||
it("classifies internal and compatibility error messages", () => {
|
||||
|
||||
@@ -52,6 +52,7 @@ const ERROR_PATTERNS = {
|
||||
"credit balance",
|
||||
"plans & billing",
|
||||
"insufficient balance",
|
||||
"insufficient usd or diem balance",
|
||||
],
|
||||
authPermanent: [
|
||||
/api[_ ]?key[_ ]?(?:revoked|invalid|deactivated|deleted)/i,
|
||||
|
||||
Reference in New Issue
Block a user