(fix): handle Cloudflare 521 and transient 5xx errors gracefully (#13500)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: a8347e95c5
Co-authored-by: rodrigouroz <384037+rodrigouroz@users.noreply.github.com>
Co-authored-by: Takhoffman <781889+Takhoffman@users.noreply.github.com>
Reviewed-by: @Takhoffman
This commit is contained in:
Rodrigo Uroz
2026-02-12 00:42:33 -03:00
committed by GitHub
parent c28cbac512
commit b912d3992d
10 changed files with 310 additions and 2 deletions

View File

@@ -22,4 +22,16 @@ describe("formatRawAssistantErrorForUi", () => {
"HTTP 500: Internal Server Error",
);
});
it("sanitizes HTML error pages into a clean unavailable message", () => {
const htmlError = `521 <!DOCTYPE html>
<html lang="en-US">
<head><title>Web server is down | example.com | Cloudflare</title></head>
<body>Ray ID: abc123</body>
</html>`;
expect(formatRawAssistantErrorForUi(htmlError)).toBe(
"The AI service is temporarily unavailable (HTTP 521). Please try again in a moment.",
);
});
});