fix: detect and sanitize HTML error pages in agent responses
This commit is contained in:
parent
fa4222fdee
commit
6f37fe0acc
@ -12,6 +12,7 @@ Docs: https://docs.clawd.bot
|
|||||||
### Fixes
|
### Fixes
|
||||||
- Web UI: hide internal `message_id` hints in chat bubbles.
|
- Web UI: hide internal `message_id` hints in chat bubbles.
|
||||||
- Heartbeat: normalize target identifiers for consistent routing.
|
- Heartbeat: normalize target identifiers for consistent routing.
|
||||||
|
- Agent errors: detect and sanitize HTML error pages from external APIs (prevents Next.js 404 pages being sent to messaging channels).
|
||||||
|
|
||||||
## 2026.1.23-1
|
## 2026.1.23-1
|
||||||
|
|
||||||
|
|||||||
@ -273,6 +273,12 @@ export function formatAssistantErrorText(
|
|||||||
return formatRawAssistantErrorForUi(raw);
|
return formatRawAssistantErrorForUi(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect HTML error pages (e.g., Next.js 404s from misconfigured API endpoints)
|
||||||
|
if (raw.includes("<!DOCTYPE") || raw.includes("<html") || /<head[\s>]/.test(raw)) {
|
||||||
|
console.warn("[formatAssistantErrorText] HTML error page received:", raw.slice(0, 200));
|
||||||
|
return "The AI service returned an unexpected error page. The API endpoint may be misconfigured or temporarily unavailable.";
|
||||||
|
}
|
||||||
|
|
||||||
// Never return raw unhandled errors - log for debugging but return safe message
|
// Never return raw unhandled errors - log for debugging but return safe message
|
||||||
if (raw.length > 600) {
|
if (raw.length > 600) {
|
||||||
console.warn("[formatAssistantErrorText] Long error truncated:", raw.slice(0, 200));
|
console.warn("[formatAssistantErrorText] Long error truncated:", raw.slice(0, 200));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user