danielmiessler/Fabric · error · Error
Fabric API error: ${fabricResponse.statusText}
Error message
Fabric API error: ${fabricResponse.statusText} What it means
Thrown by the SvelteKit /chat server endpoint when it proxies the request to the local Fabric backend and fabricResponse.ok is false. The Fabric REST service (fabric --serve) returned a 4xx/5xx; common causes are an unknown pattern name, missing/invalid API key for the configured vendor, an unreachable or misconfigured model, or the server rejecting the request payload. The thrown message only carries statusText, which hides the backend's error body.
Source
Thrown at web/src/routes/chat/+server.ts:111
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body)
});
console.log('6. Fabric response:', {
status: fabricResponse.status,
ok: fabricResponse.ok,
statusText: fabricResponse.statusText
});
if (!fabricResponse.ok) {
console.error('Error from Fabric API:', {
status: fabricResponse.status,
statusText: fabricResponse.statusText
});
throw new Error(`Fabric API error: ${fabricResponse.statusText}`);
}
const stream = fabricResponse.body;
if (!stream) {
throw new Error('No response from fabric backend');
}
// Create a TransformStream to inspect the data without modifying it
const transformStream = new TransformStream({
transform(chunk, controller) {
const text = new TextDecoder().decode(chunk);
if (text.startsWith('data: ')) {
try {
const data = JSON.parse(text.slice(6));
console.log('Stream chunk format:', {
type: data.type,
format: data.format,
contentLength: data.content?.lengthView on GitHub (pinned to 338b89cfe9)
Solutions
- Read the Fabric server's own logs/console output for the matching request — the endpoint already logs status and statusText just above the throw
- Verify the vendor API keys exist in Fabric's .env and that the selected model is valid for that vendor
- Confirm the pattern name sent in the request exists (fabric --listpatterns / patterns dir) and matches exactly
- Check the FABRIC backend URL/port the endpoint targets and that the running fabric --serve version matches what the UI expects
- Forward the backend error body instead of statusText so the UI shows the real reason
Example fix
// before
if (!fabricResponse.ok) {
console.error('Error from Fabric API:', { status: fabricResponse.status, statusText: fabricResponse.statusText });
throw new Error(`Fabric API error: ${fabricResponse.statusText}`);
}
// after
if (!fabricResponse.ok) {
const errBody = await fabricResponse.text().catch(() => '');
console.error('Error from Fabric API:', { status: fabricResponse.status, statusText: fabricResponse.statusText, body: errBody });
throw error(fabricResponse.status, `Fabric API error: ${errBody || fabricResponse.statusText}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Sanity-check the request before proxying
if (!pattern) throw error(400, 'Missing pattern');
const fabricBase = env.FABRIC_URL ?? 'http://localhost:8080';
// Optional liveness probe before the real call
const health = await fetch(`${fabricBase}/health`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
if (!health?.ok) throw error(502, 'Fabric backend unreachable'); Try / catch
try {
const fabricResponse = await fetch(fabricUrl, { ...init });
if (!fabricResponse.ok) {
const errBody = await fabricResponse.text().catch(() => '');
throw error(fabricResponse.status, `Fabric API error: ${errBody || fabricResponse.statusText}`);
}
// ... stream
} catch (e) {
if (e && typeof e === 'object' && 'status' in e) throw e; // sveltekit HttpError passthrough
throw error(502, `Fabric backend request failed: ${String(e)}`);
} Prevention
- Surface the Fabric error body, not just statusText — statusText is empty under HTTP/2
- Keep fabric CLI and web UI versions in lockstep; breaking changes usually appear as 404s on routes
- Verify vendor API keys are configured in fabric's .env before selecting that vendor in the UI
- Confirm the pattern exists (fabric --listpatterns) when adding dynamic pattern selection
When it happens
Trigger: POST /chat with a pattern the backend does not have (404), vendor API key missing/expired (401/500 from Fabric), model name not available to the vendor (400), Fabric server on a different port or an older version with different routes (404), or payload fields the server rejects (422).
Common situations: Fabric config (~/.config/fabric/.env) missing OPENAI/ANTHROPIC keys, pattern renamed or removed from the patterns dir, Fabric CLI updated with breaking API changes while the web UI was not, env vars not loaded into the process serving the endpoint.
Related errors
- HTTP error! status: ${response.status}
- await response.text()
- Failed to load session: ${response.statusText}
- No output received from create_pattern
- HTTP_ERROR
AI-assisted analysis of danielmiessler/Fabric@338b89cfe9 (2026-08-15).
Data as JSON: /api/errors/3d09d740884a70d2.
Report an issue: GitHub.