{"record":{"id":"642ded003b97977f","repo":"microsoft/autogen","slug":"failed-to-fetch-team","errorCode":null,"errorMessage":"Failed to fetch team","messagePattern":"Failed to fetch team","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-studio/frontend/src/components/views/teambuilder/api.ts","lineNumber":44,"sourceCode":"      `${this.getBaseUrl()}/teams/?user_id=${userId}`,\n      {\n        headers: this.getHeaders(),\n      }\n    );\n    const data = await response.json();\n    if (!data.status) throw new Error(data.message || \"Failed to fetch teams\");\n    return data.data;\n  }\n\n  async getTeam(teamId: number, userId: string): Promise<Team> {\n    const response = await fetch(\n      `${this.getBaseUrl()}/teams/${teamId}?user_id=${userId}`,\n      {\n        headers: this.getHeaders(),\n      }\n    );\n    const data = await response.json();\n    if (!data.status) throw new Error(data.message || \"Failed to fetch team\");\n    return data.data;\n  }\n\n  async createTeam(teamData: Partial<Team>, userId: string): Promise<Team> {\n    const team = {\n      ...teamData,\n      user_id: userId,\n    };\n\n    const response = await fetch(`${this.getBaseUrl()}/teams/`, {\n      method: \"POST\",\n      headers: this.getHeaders(),\n      body: JSON.stringify(team),\n    });\n    const data = await response.json();\n    if (!data.status) throw new Error(data.message || \"Failed to create team\");\n    return data.data;\n  }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/teambuilder/api.ts#L26-L62","documentation":"Thrown by TeamAPI.getTeam when GET /teams/{id}?user_id=... returns falsy status. The standard cause is a team id that does not exist or is owned by a different user_id — the backend's ownership check answers through the status envelope.","triggerScenarios":"GET /teams/{teamId}?user_id=X for a deleted team, another user's team, or after a DB reset wiped team rows while the UI kept a stale id.","commonSituations":"Gallery/team link opened after the team was deleted, user switch without clearing selected team state, backend DB recreated (teams gone, frontend state persists).","solutions":["Check the id against listTeams(userId) output before loading it","Clear stale selected-team state on user change or on 404-flavored messages","Read data.message for the backend wording","If the list is empty, re-create or re-import the team rather than retrying the id"],"exampleFix":"// before\nconst team = await teamAPI.getTeam(teamId, userId);\n// after\nconst teams = await teamAPI.listTeams(userId);\nconst team = teams.find(t => t.id === teamId);\nif (!team) throw new Error(`Team ${teamId} not found for this user`);","handlingStrategy":"try-catch","validationCode":"const teams = await teamAPI.listTeams(userId);\nif (!teams.some(t => t.id === teamId)) {\n  throw new Error(`Team ${teamId} not found for this user`);\n}","typeGuard":"function isTeamEnvelope(x: unknown): x is { status: true; data: Team } {\n  return !!x && (x as any).status === true && !!(x as any).data?.id;\n}","tryCatchPattern":"try {\n  return await teamAPI.getTeam(teamId, userId);\n} catch (e) {\n  if (/not found|does not exist/i.test(String(e))) navigateToTeamsList();\n  throw e;\n}","preventionTips":["Validate deep-linked team ids against the list on mount","Clear selected team state on user switch or logout","Handle 'not found' as navigation, not an error toast"],"tags":["teams","http","error-envelope"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}