danielmiessler/Fabric · error · Error

Failed to load session: ${response.statusText}

Error message

Failed to load session: ${response.statusText}

What it means

Thrown by loadSessionMessages when GET /api/sessions/{sessionName} returns a non-2xx status. The message embeds response.statusText, so the actual cause is whatever the server reported (404 for a missing/deleted session, 500 for a server-side read failure, 400 for a malformed name). Note statusText is often empty in HTTP/2, so the message can be unhelpfully blank.

Source

Thrown at web/src/lib/store/session-store.ts:98

      const content = await readFileAsJson<Message[]>(file);
      if (!Array.isArray(content)) {
        throw new Error('Invalid session file format');
      }

      toastService.success('Session imported successfully');
      return content;
    } catch (error) {
      toastService.error(error instanceof Error ? error.message : 'Failed to import session');
      throw error;
    }
  },

  async loadSessionMessages(sessionName: string): Promise<Message[]> {
    try {
      const response = await fetch(`/api/sessions/${sessionName}`);
      if (!response.ok) {
        throw new Error(`Failed to load session: ${response.statusText}`);
      }
      const data = await response.json();
      const messages = Array.isArray(data.Message) ? data.Message : [];
      return messages;
    } catch (error) {
      console.error(`Error loading session messages for ${sessionName}:`, error);
      throw error;
    }
  }
};

View on GitHub (pinned to 338b89cfe9)

Solutions

  1. Check the Network tab for the real status code, then verify the session file still exists on the server under the sessions directory
  2. URL-encode the name: fetch(`/api/sessions/${encodeURIComponent(sessionName)}`)
  3. Refresh the session list before loading, or remove the entry from the list on 404 instead of surfacing a raw error
  4. Include response.status in the message (and a body error field if the API sends one) since statusText is frequently empty under HTTP/2

Example fix

// before
const response = await fetch(`/api/sessions/${sessionName}`);
if (!response.ok) {
  throw new Error(`Failed to load session: ${response.statusText}`);
}

// after
const response = await fetch(`/api/sessions/${encodeURIComponent(sessionName)}`);
if (!response.ok) {
  const body = await response.json().catch(() => null);
  throw new Error(`Failed to load session '${sessionName}': ${response.status} ${body?.error ?? response.statusText}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Before loading, check the session still exists in the known list
if (!sessionNames.includes(sessionName)) {
  throw new Error(`Unknown session: ${sessionName}`);
}
await fetch(`/api/sessions/${encodeURIComponent(sessionName)}`, { method: 'HEAD' });

Try / catch

try {
  const response = await fetch(`/api/sessions/${encodeURIComponent(sessionName)}`);
  if (response.status === 404) return []; // deleted session: treat as empty, prune list
  if (!response.ok) {
    const body = await response.json().catch(() => null);
    throw new Error(`Failed to load session (${response.status}): ${body?.error ?? response.statusText}`);
  }
  const data = await response.json();
  return Array.isArray(data.Message) ? data.Message : [];
} catch (error) {
  console.error(`Error loading session messages for ${sessionName}:`, error);
  throw error;
}

Prevention

When it happens

Trigger: Clicking a session in the UI whose backing file was deleted or renamed on disk (404); a sessionName containing path characters or spaces that break the URL (400/404); the backend server being down or proxying failing (502/500); a race where the session list is stale relative to the filesystem.

Common situations: Sessions directory edited outside the app, session renamed manually, reverse proxy returning 502 while the API restarts, URL-encoding bugs where sessionName is interpolated into the path unencoded, or the API route expecting a different name format (e.g. with/without .json extension).

Related errors


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