Merge 4be25a6866e7168c7f8d502ad016ba18822877d6 into 5e417b44e1540f528d2ae63e3e20229a902d1db2
This commit is contained in:
commit
aacc0f44fd
@ -860,4 +860,18 @@ describe("classifyFailoverReason", () => {
|
||||
),
|
||||
).toBe("timeout");
|
||||
});
|
||||
it("classifies generic provider errors as timeout", () => {
|
||||
expect(classifyFailoverReason("An unknown error occurred")).toBe("timeout");
|
||||
expect(classifyFailoverReason("Internal server error")).toBe("timeout");
|
||||
expect(classifyFailoverReason("Service unavailable")).toBe("timeout");
|
||||
// Case-insensitive
|
||||
expect(classifyFailoverReason("AN UNKNOWN ERROR OCCURRED")).toBe("timeout");
|
||||
// Wrapped in provider payload
|
||||
expect(classifyFailoverReason('{"error":{"message":"An unknown error occurred"}}')).toBe(
|
||||
"timeout",
|
||||
);
|
||||
// "an error occurred" alone should NOT match (too broad)
|
||||
expect(classifyFailoverReason("An error occurred")).toBeNull();
|
||||
expect(classifyFailoverReason("A validation error occurred")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@ -670,6 +670,18 @@ export function isBillingAssistantError(msg: AssistantMessage | undefined): bool
|
||||
return isBillingErrorMessage(msg.errorMessage ?? "");
|
||||
}
|
||||
|
||||
function isGenericProviderError(raw: string): boolean {
|
||||
if (!raw) {
|
||||
return false;
|
||||
}
|
||||
const lower = raw.toLowerCase();
|
||||
return (
|
||||
lower.includes("an unknown error occurred") ||
|
||||
lower.includes("internal server error") ||
|
||||
lower.includes("service unavailable")
|
||||
);
|
||||
}
|
||||
|
||||
function isJsonApiInternalServerError(raw: string): boolean {
|
||||
if (!raw) {
|
||||
return false;
|
||||
@ -848,6 +860,9 @@ export function classifyFailoverReason(raw: string): FailoverReason | null {
|
||||
if (isAuthErrorMessage(raw)) {
|
||||
return "auth";
|
||||
}
|
||||
if (isGenericProviderError(raw)) {
|
||||
return "timeout";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user