fix: remove overly broad 'an error occurred' pattern
Per Greptile review feedback, the plain 'an error occurred' substring match is too permissive and could trigger false failovers for application-level errors that aren't transient provider failures. Removed this pattern from isGenericProviderError() and updated tests to verify that generic 'an error occurred' alone does NOT match, while specific patterns like 'an unknown error occurred' still do.
This commit is contained in:
parent
627743aa38
commit
4be25a6866
@ -862,15 +862,16 @@ describe("classifyFailoverReason", () => {
|
||||
});
|
||||
it("classifies generic provider errors as timeout", () => {
|
||||
expect(classifyFailoverReason("An unknown error occurred")).toBe("timeout");
|
||||
expect(classifyFailoverReason("An 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");
|
||||
expect(classifyFailoverReason("an error occurred while processing")).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();
|
||||
});
|
||||
});
|
||||
|
||||
@ -853,7 +853,6 @@ function isGenericProviderError(raw: string): boolean {
|
||||
const lower = raw.toLowerCase();
|
||||
return (
|
||||
lower.includes("an unknown error occurred") ||
|
||||
lower.includes("an error occurred") ||
|
||||
lower.includes("internal server error") ||
|
||||
lower.includes("service unavailable")
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user