mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:40:44 +00:00
fix: restrict HTML timeout short-circuit to transient statuses
This commit is contained in:
@@ -176,7 +176,7 @@ describe("formatAssistantErrorText", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("returns upstream HTML copy for prefixed HTML rate-limit pages", () => {
|
||||
it("returns upstream HTML copy for prefixed 521 HTML rate-limit pages", () => {
|
||||
const msg = makeAssistantError(
|
||||
"Error: 521 <!DOCTYPE html><html><body>rate limit</body></html>",
|
||||
);
|
||||
|
||||
@@ -354,7 +354,11 @@ function isHtmlErrorResponse(raw: string, status?: number): boolean {
|
||||
}
|
||||
|
||||
function isTransportHtmlErrorStatus(status: number | undefined): boolean {
|
||||
return status !== 401 && status !== 403 && status !== 407;
|
||||
return (
|
||||
status === 408 ||
|
||||
status === 499 ||
|
||||
(typeof status === "number" && status >= 500 && status < 600)
|
||||
);
|
||||
}
|
||||
|
||||
function isOpenAICodexScopeContext(raw: string, provider?: string): boolean {
|
||||
|
||||
@@ -167,6 +167,12 @@ describe("Cloudflare / CDN HTML error page classification (#67517)", () => {
|
||||
const html407 =
|
||||
"<!doctype html><html><head><title>407 Proxy Authentication Required</title></head>" +
|
||||
"<body><h1>Proxy Authentication Required</h1></body></html>";
|
||||
const html402 =
|
||||
"<!doctype html><html><head><title>402 Payment Required</title></head>" +
|
||||
"<body><h1>Payment Required</h1><p>Your quota is exhausted.</p></body></html>";
|
||||
const html429 =
|
||||
"<!doctype html><html><head><title>429 Too Many Requests</title></head>" +
|
||||
"<body><h1>Too Many Requests</h1><p>Rate limit exceeded.</p></body></html>";
|
||||
const prefixedHtml401 = `Error: 401 ${html401}`;
|
||||
const prefixedHtml407 = `Error: 407 ${html407}`;
|
||||
|
||||
@@ -190,6 +196,14 @@ describe("Cloudflare / CDN HTML error page classification (#67517)", () => {
|
||||
expect(classifyFailoverReason(prefixedHtml401)).toBe("auth");
|
||||
});
|
||||
|
||||
it("preserves billing classification for 402 HTML", () => {
|
||||
expect(classifyFailoverReason(`402 ${html402}`)).toBe("billing");
|
||||
});
|
||||
|
||||
it("preserves rate-limit classification for 429 HTML", () => {
|
||||
expect(classifyFailoverReason(`429 ${html429}`)).toBe("rate_limit");
|
||||
});
|
||||
|
||||
it("classifies runtime failure kind as upstream_html for non-auth HTML", () => {
|
||||
expect(classifyProviderRuntimeFailureKind({ status: 502, message: cloudflareHtml502 })).toBe(
|
||||
"upstream_html",
|
||||
|
||||
Reference in New Issue
Block a user