danielmiessler/Fabric · error · Error

errorData.error || `HTTP error! status: ${response.status}`

Error message

errorData.error || `HTTP error! status: ${response.status}`

What it means

transcriptService throws the server's errorData.error (or the generic HTTP status fallback) when its fetch responds non-OK. The endpoint returned JSON with an error field, which is relayed verbatim; the fallback fires when the body is not JSON or lacks error.

Source

Thrown at web/src/lib/services/transcriptService.ts:48

        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        url,
        language: originalLanguage // Pass original language to server
      })
    });

    console.log('2. Server response:', {
      status: response.status,
      ok: response.ok,
      type: response.type,
      originalLanguage,
      currentLanguage: get(languageStore)
    });

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(errorData.error || `HTTP error! status: ${response.status}`);
    }

    const data = await response.json();
    if (data.error) {
      throw new Error(data.error);
    }

    // Decode HTML entities in transcript
    data.transcript = decodeHtmlEntities(data.transcript);

    // Ensure language is preserved
    if (get(languageStore) !== originalLanguage) {
      console.log('3a. Restoring original language:', originalLanguage);
      languageStore.set(originalLanguage);
    }

    console.log('3b. Processed transcript:', {
      status: response.status,

View on GitHub (pinned to 338b89cfe9)

Solutions

  1. Read errorData.error — it names the exact server-side cause (no captions, fetch failure, bad URL)
  2. Verify the video actually has subtitles in the requested language
  3. If response.json() itself throws, handle non-JSON error bodies by falling back to response.text()

Example fix

// before
if (!response.ok) {
  const errorData = await response.json();
  throw new Error(errorData.error || `HTTP error! status: ${response.status}`);
}

// after
if (!response.ok) {
  const text = await response.text();
  let msg = `HTTP error! status: ${response.status}`;
  try { msg = JSON.parse(text).error || msg; } catch { if (text) msg = text; }
  throw new Error(msg);
}
Defensive patterns

Strategy: try-catch

Type guard

function isTranscriptHttpError(e: unknown): boolean {
  return e instanceof Error && /HTTP error! status/.test(e.message);
}

Try / catch

try { transcript = await transcriptService.get(videoUrl); }
catch (e) {
  if (isTranscriptHttpError(e) || (e instanceof Error && /caption|subtitle/i.test(e.message))) {
    disableTranscriptFeature(videoUrl); // expected for caption-less videos
  } else throw e;
}

Prevention

When it happens

Trigger: Requesting a transcript for a video whose language/translation the server cannot fetch; missing subtitles for the requested language; invalid video URL; downstream YouTube-dl service failing so the handler answers 4xx/5xx with an error body.

Common situations: Video has no captions in the chosen language; transcript service rate-limited or blocked; malformed video ID; languageStore changed mid-request causing a language mismatch server-side.

Related errors


AI-assisted analysis of danielmiessler/Fabric@338b89cfe9 (2026-08-15). Data as JSON: /api/errors/1a3fdc9bd6936daf. Report an issue: GitHub.