{"record":{"id":"b1ae10c47eeec1fa","repo":"danielmiessler/Fabric","slug":"failed-to-load-session-response-statustext","errorCode":null,"errorMessage":"Failed to load session: ${response.statusText}","messagePattern":"Failed to load session: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/lib/store/session-store.ts","lineNumber":98,"sourceCode":"\n      const content = await readFileAsJson<Message[]>(file);\n      if (!Array.isArray(content)) {\n        throw new Error('Invalid session file format');\n      }\n\n      toastService.success('Session imported successfully');\n      return content;\n    } catch (error) {\n      toastService.error(error instanceof Error ? error.message : 'Failed to import session');\n      throw error;\n    }\n  },\n\n  async loadSessionMessages(sessionName: string): Promise<Message[]> {\n    try {\n      const response = await fetch(`/api/sessions/${sessionName}`);\n      if (!response.ok) {\n        throw new Error(`Failed to load session: ${response.statusText}`);\n      }\n      const data = await response.json();\n      const messages = Array.isArray(data.Message) ? data.Message : [];\n      return messages;\n    } catch (error) {\n      console.error(`Error loading session messages for ${sessionName}:`, error);\n      throw error;\n    }\n  }\n};\n","sourceCodeStart":80,"sourceCodeEnd":109,"githubUrl":"https://github.com/danielmiessler/Fabric/blob/338b89cfe97ab2d12ce30ce8b5449857a841366d/web/src/lib/store/session-store.ts#L80-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Check the Network tab for the real status code, then verify the session file still exists on the server under the sessions directory","URL-encode the name: fetch(`/api/sessions/${encodeURIComponent(sessionName)}`)","Refresh the session list before loading, or remove the entry from the list on 404 instead of surfacing a raw error","Include response.status in the message (and a body error field if the API sends one) since statusText is frequently empty under HTTP/2"],"exampleFix":"// before\nconst response = await fetch(`/api/sessions/${sessionName}`);\nif (!response.ok) {\n  throw new Error(`Failed to load session: ${response.statusText}`);\n}\n\n// after\nconst response = await fetch(`/api/sessions/${encodeURIComponent(sessionName)}`);\nif (!response.ok) {\n  const body = await response.json().catch(() => null);\n  throw new Error(`Failed to load session '${sessionName}': ${response.status} ${body?.error ?? response.statusText}`);\n}","handlingStrategy":"try-catch","validationCode":"// Before loading, check the session still exists in the known list\nif (!sessionNames.includes(sessionName)) {\n  throw new Error(`Unknown session: ${sessionName}`);\n}\nawait fetch(`/api/sessions/${encodeURIComponent(sessionName)}`, { method: 'HEAD' });","typeGuard":null,"tryCatchPattern":"try {\n  const response = await fetch(`/api/sessions/${encodeURIComponent(sessionName)}`);\n  if (response.status === 404) return []; // deleted session: treat as empty, prune list\n  if (!response.ok) {\n    const body = await response.json().catch(() => null);\n    throw new Error(`Failed to load session (${response.status}): ${body?.error ?? response.statusText}`);\n  }\n  const data = await response.json();\n  return Array.isArray(data.Message) ? data.Message : [];\n} catch (error) {\n  console.error(`Error loading session messages for ${sessionName}:`, error);\n  throw error;\n}","preventionTips":["URL-encode path parameters interpolated into fetch URLs","Include response.status (and parsed body error) in thrown messages — statusText is empty on HTTP/2","Refresh/prune the session list when entries 404 instead of retrying stale names"],"tags":["network","http","session-store","api"],"backgroundTag":null,"analyzedSha":"338b89cfe97ab2d12ce30ce8b5449857a841366d","analyzedAt":"2026-08-15T11:38:51.759Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}