danielmiessler/Fabric · error · ChatError
HTTP_ERROR
HTTP_ERROR
Error message
HTTP error! status: ${response.status} What it means
ChatService.sendMessage throws ChatError('HTTP error! status: N', 'HTTP_ERROR') when POST /api/chat returns non-2xx before streaming begins. The logged 'Final ChatRequest payload' immediately above is the exact body that was rejected, which is the key debugging artifact.
Source
Thrown at web/src/lib/services/ChatService.ts:70
language: get(languageStore),
pattern: get(selectedPatternName),
promptCount: request.prompts?.length,
messageCount: request.messages?.length,
});
// NEW: Log the full payload before sending to backend
console.log(
"Final ChatRequest payload:",
JSON.stringify(request, null, 2),
);
const response = await fetch("/api/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(request),
});
if (!response.ok) {
throw new ChatError(
`HTTP error! status: ${response.status}`,
"HTTP_ERROR",
{ status: response.status },
);
}
const reader = response.body?.getReader();
if (!reader) {
throw new ChatError("Response body is null", "NULL_RESPONSE");
}
return this.createMessageStream(reader);
} catch (error) {
if (error instanceof ChatError) throw error;
throw new ChatError("Failed to fetch chat stream", "FETCH_ERROR", error);
}
}
View on GitHub (pinned to 338b89cfe9)
Solutions
- Open devtools Network tab, take the logged 'Final ChatRequest payload', and replay it with curl to see the server's error body
- Verify every field of the request (pattern, model, vendor) exists server-side
- Fix the server-side cause (restore pattern, re-pull model, set API key)
Defensive patterns
Strategy: try-catch
Validate before calling
const models = await modelsApi.getAvailable();
if (!models.some(m => m.name === request.model && m.vendor === request.vendor)) {
throw new Error(`Model ${request.vendor}/${request.model} is not available`);
} Type guard
function isChatHttpError(e: unknown): e is ChatError & { code: 'HTTP_ERROR' } {
return e instanceof ChatError && e.code === 'HTTP_ERROR';
} Try / catch
try { stream = await chatService.sendMessage(request); }
catch (e) {
if (isChatHttpError(e)) {
const status = (e.details as any)?.status;
if (status === 404 || status === 400) showUserFixableMessage(); // bad pattern/model
else showServerError();
} else throw e;
} Prevention
- Validate pattern/model/vendor against the fetched model list before sending
- Match frontend request schema to the backend's current /api/chat contract
When it happens
Trigger: POST /api/chat with a request referencing an unknown pattern/model/vendor (400/404), backend LLM provider unreachable (5xx), or malformed request JSON the chat handler rejects.
Common situations: Pattern renamed or missing server-side; selected model no longer available (Ollama model pulled); API key for the vendor missing server-side; backend upgraded with breaking request-schema changes while the frontend is stale.
Related errors
- HTTP error! status: ${response.status}
- NULL_RESPONSE
- STREAM_CONTENT_ERROR
- errorData.error || `HTTP error! status: ${response.status}`
- await response.text()
AI-assisted analysis of danielmiessler/Fabric@338b89cfe9 (2026-08-15).
Data as JSON: /api/errors/b256b90eeea06621.
Report an issue: GitHub.