mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:40:44 +00:00
Avoid rescanning HTML challenge pages during error formatting
The HTML challenge fix already keeps standalone CDN block pages out of the DNS transport path. This follow-up caches the HTML classification so status-prefixed non-HTML failures do not pay for the same scan twice and the control flow stays simpler. Constraint: Keep behavior identical for both status-prefixed HTML pages and standalone HTML challenge pages Rejected: Inline the helper into the status branch only | would duplicate the standalone HTML branch logic Confidence: high Scope-risk: narrow Directive: If this formatter grows more branches, keep a single HTML classification result and reuse it through the decision tree Tested: oxfmt --check src/shared/assistant-error-format.ts Tested: node scripts/test-projects.mjs src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts
This commit is contained in:
committed by
Peter Steinberger
parent
36dd58ac2a
commit
59caf03d67
@@ -182,11 +182,12 @@ export function formatRawAssistantErrorForUi(raw?: string): string {
|
||||
}
|
||||
|
||||
const leadingStatus = extractLeadingHttpStatus(trimmed);
|
||||
if (leadingStatus && isCloudflareOrHtmlErrorPage(trimmed)) {
|
||||
const isHtmlChallenge = isCloudflareOrHtmlErrorPage(trimmed);
|
||||
if (leadingStatus && isHtmlChallenge) {
|
||||
return `The AI service is temporarily unavailable (HTTP ${leadingStatus.code}). Please try again in a moment.`;
|
||||
}
|
||||
|
||||
if (isCloudflareOrHtmlErrorPage(trimmed)) {
|
||||
if (isHtmlChallenge) {
|
||||
return (
|
||||
"The provider returned an HTML error page instead of an API response. " +
|
||||
"This usually means a CDN or gateway (e.g. Cloudflare) blocked the request. " +
|
||||
|
||||
Reference in New Issue
Block a user