{"record":{"id":"7bde6f18288ea4d7","repo":"microsoft/autogen","slug":"failed-to-fetch-teams","errorCode":null,"errorMessage":"Failed to fetch teams","messagePattern":"Failed to fetch teams","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-studio/frontend/src/components/views/teambuilder/api.ts","lineNumber":32,"sourceCode":"}\n\nexport interface ComponentTestResult {\n  status: boolean;\n  message: string;\n  data?: any;\n  logs: string[];\n}\n\nexport class TeamAPI extends BaseAPI {\n  async listTeams(userId: string): Promise<Team[]> {\n    const response = await fetch(\n      `${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,","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/teambuilder/api.ts#L14-L50","documentation":"Thrown by TeamAPI.listTeams when GET /teams/?user_id=... returns falsy status. Same envelope contract as the other studio APIs: HTTP status is not checked, only data.status. Usual causes are an unregistered user_id, auth failure, or DB error.","triggerScenarios":"GET /teams/?user_id=X returning {status:false}: user_id unknown to the backend, token invalid/expired, or the teams table unreachable.","commonSituations":"Teambuilder loaded before the user record exists on a fresh backend, switching auth realms while keeping an old user_id in state, backend started against an empty/unmigrated DB.","solutions":["Inspect data.message in DevTools for the backend's reason","Confirm user_id matches the authenticated user and exists on the backend","Verify the backend DB is migrated and reachable","curl the endpoint with the Bearer token to see the raw envelope"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function isValidUserId(u: string | undefined | null): u is string {\n  return typeof u === \"string\" && u.length > 0;\n}","typeGuard":"function isTeamListEnvelope(x: unknown): x is { status: true; data: Team[] } {\n  return !!x && (x as any).status === true && Array.isArray((x as any).data);\n}","tryCatchPattern":"try {\n  setTeams(await teamAPI.listTeams(userId));\n} catch (e) {\n  setTeams([]);\n  notify(e instanceof Error ? e.message : \"Failed to fetch teams\");\n}","preventionTips":["Load teams only after user context resolves","Verify backend DB migration status on fresh installs","Check both response.ok and data.status in a shared wrapper to classify auth vs data errors"],"tags":["teams","http","error-envelope","fetch"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}