test(live): classify provider HTTP 5xx as server drift

This commit is contained in:
Vincent Koc
2026-05-05 01:05:54 -07:00
parent 61383aff4b
commit 9c4a335007
2 changed files with 6 additions and 1 deletions

View File

@@ -99,6 +99,10 @@ describe("server error status classification", () => {
expect(isServerErrorMessage("status: internal server error")).toBe(true);
});
it("classifies provider HTTP 5xx wrapper errors as server errors", () => {
expect(isServerErrorMessage("provider failed (HTTP 500): upstream apiKey is empty")).toBe(true);
});
it("does not classify prefixed plain internal server error status prose", () => {
expect(isServerErrorMessage("Proxy notice: Status: Internal Server Error")).toBe(false);
});

View File

@@ -53,6 +53,7 @@ const ZAI_AUTH_CODE_1113_RE = /"code"\s*:\s*1113\b/;
const STATUS_INTERNAL_SERVER_ERROR_RE = /\bstatus:\s*internal server error\b/i;
const STATUS_INTERNAL_SERVER_ERROR_WITH_500_RE =
/^(?=[\s\S]*\bstatus:\s*internal server error\b)(?=[\s\S]*\bcode["']?\s*[:=]\s*500\b)/i;
const HTTP_5XX_STATUS_RE = /\bHTTP\s+5\d\d\b/i;
const ZAI_AUTH_ERROR_PATTERNS = [
// Z.ai: error 1113 = wrong endpoint or invalid credentials (#48988)
@@ -305,7 +306,7 @@ export function isServerErrorMessage(raw: string): boolean {
if (!value) {
return false;
}
if (STATUS_INTERNAL_SERVER_ERROR_WITH_500_RE.test(value)) {
if (STATUS_INTERNAL_SERVER_ERROR_WITH_500_RE.test(value) || HTTP_5XX_STATUS_RE.test(value)) {
return true;
}
const scrubbed = value.replace(STATUS_INTERNAL_SERVER_ERROR_RE, "").trim();