{"record":{"id":"6a1c131fd2632d6f","repo":"microsoft/autogen","slug":"failed-to-fetch-session-runs","errorCode":null,"errorMessage":"Failed to fetch session runs","messagePattern":"Failed to fetch session runs","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-studio/frontend/src/components/views/playground/api.ts","lineNumber":89,"sourceCode":"    if (!data.status)\n      throw new Error(data.message || \"Failed to update session\");\n    return data.data;\n  }\n\n  // session runs with messages\n  async getSessionRuns(\n    sessionId: number,\n    userId: string\n  ): Promise<SessionRuns> {\n    const response = await fetch(\n      `${this.getBaseUrl()}/sessions/${sessionId}/runs?user_id=${userId}`,\n      {\n        headers: this.getHeaders(),\n      }\n    );\n    const data = await response.json();\n    if (!data.status)\n      throw new Error(data.message || \"Failed to fetch session runs\");\n    return data.data; // Returns { runs: RunMessage[] }\n  }\n\n  async deleteSession(sessionId: number, userId: string): Promise<void> {\n    const response = await fetch(\n      `${this.getBaseUrl()}/sessions/${sessionId}?user_id=${userId}`,\n      {\n        method: \"DELETE\",\n        headers: this.getHeaders(),\n      }\n    );\n    const data = await response.json();\n    if (!data.status)\n      throw new Error(data.message || \"Failed to delete session\");\n  }\n\n  // Adding messages endpoint\n  async listSessionMessages(sessionId: number, userId: string): Promise<any[]> {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/playground/api.ts#L71-L107","documentation":"Thrown by SessionAPI.getSessionRuns when GET /sessions/{id}/runs?user_id=... returns falsy status. This endpoint returns run transcripts; failure means the session id/user pair is invalid or the backend failed loading runs. The comment notes the success shape is {runs: RunMessage[]}.","triggerScenarios":"GET /sessions/{sessionId}/runs?user_id=X for a nonexistent/deleted session, ownership mismatch, or a backend error while querying run/message tables.","commonSituations":"Opening run history for a session whose rows were purged, backend DB migration leaving run tables inconsistent, stale sessionId in a long-lived playground tab.","solutions":["Verify the session exists first via getSession(sessionId, userId)","Inspect data.message for the backend's stated reason","If session validity is confirmed and it still fails, check backend logs for the runs query error","Guard the UI so a runs-load failure doesn't blank the whole session view"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"await sessionAPI.getSession(sessionId, userId); // throws a clearer error if session invalid","typeGuard":"function isSessionRunsEnvelope(x: unknown): x is { status: true; data: { runs: unknown[] } } {\n  return !!x && (x as any).status === true && Array.isArray((x as any).data?.runs);\n}","tryCatchPattern":"try {\n  const { runs } = (await sessionAPI.getSessionRuns(sessionId, userId)).data as any;\n  return runs ?? [];\n} catch {\n  return []; // runs history is non-critical — degrade gracefully\n}","preventionTips":["Treat runs history as optional data; never block the session view on it","Cache the last successful runs locally so transient failures don't blank the UI"],"tags":["sessions","runs","http","error-envelope"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}