{"record":{"id":"c59c1e1a52e1fdfa","repo":"tinyhumansai/openhuman","slug":"agentteamapi-get-teamid-is-required","errorCode":null,"errorMessage":"agentTeamApi.get: teamId is required","messagePattern":"agentTeamApi\\.get: teamId is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/services/api/agentTeamApi.ts","lineNumber":199,"sourceCode":"   */\n  list: async (params: AgentTeamListParams = {}): Promise<AgentTeam[]> => {\n    assertPositiveInt(params.limit, 'limit');\n    log('list params=%o', params);\n    const response = await callCoreRpc<{ teams?: AgentTeam[]; count?: number }>({\n      method: 'openhuman.agent_team_list',\n      params,\n    });\n    const teams = response.teams ?? [];\n    log('list received teams=%d count=%o', teams.length, response.count);\n    return teams;\n  },\n\n  /**\n   * Fetch one team plus its members and tasks. Returns `null` when the id is\n   * unknown (the controller answers `{ team: null }`).\n   */\n  get: async (teamId: string): Promise<TeamView | null> => {\n    if (!teamId) throw new Error('agentTeamApi.get: teamId is required');\n    log('get teamId=%s', teamId);\n    const response = await callCoreRpc<{ team: TeamView | null }>({\n      method: 'openhuman.agent_team_get',\n      params: { teamId },\n    });\n    log('get found=%o', response.team != null);\n    return response.team ?? null;\n  },\n\n  /**\n   * List a team's teammate messages in sequence order. Unwraps the\n   * `{ messages }` envelope and narrows each run-event payload to a typed\n   * {@link TeamMessagePayload}.\n   */\n  listMessages: async (teamId: string, limit?: number): Promise<TeamMessage[]> => {\n    if (!teamId) throw new Error('agentTeamApi.listMessages: teamId is required');\n    assertPositiveInt(limit, 'limit');\n    log('listMessages teamId=%s limit=%o', teamId, limit);","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/app/src/services/api/agentTeamApi.ts#L181-L217","documentation":"Guard inside agentTeamApi.get: the team id argument is checked for truthiness before issuing the openhuman.agent_team_get RPC. An empty/whitespace-free falsy id means the caller has no team reference and the request would be meaningless, so it throws immediately.","triggerScenarios":"Calling agentTeamApi.get(''), agentTeamApi.get(undefined as any), or get(id) where id came from an unset route param / unselected list item. Only a non-empty string reaches callCoreRpc.","commonSituations":"A detail panel rendered before a team is selected in the list; a route like /teams/:teamId mounted with no id; a store field still null on first render feeding get() directly.","solutions":["Only call get() once a team id exists — gate the effect/handler on the id being non-empty","Default the selector to skip the fetch: if (!teamId) return null instead of calling the API","Fix the upstream state so the empty id never reaches this layer"],"exampleFix":"// before\nuseEffect(() => { agentTeamApi.get(selectedTeamId).then(setTeam); }, [selectedTeamId]);\n\n// after\nuseEffect(() => {\n  if (!selectedTeamId) { setTeam(null); return; }\n  agentTeamApi.get(selectedTeamId).then(setTeam).catch(notify);\n}, [selectedTeamId]);","handlingStrategy":"validation","validationCode":"const hasTeamId = (id: string | null | undefined): id is string => typeof id === 'string' && id.length > 0;\nif (!hasTeamId(teamId)) { setTeam(null); } else { agentTeamApi.get(teamId).then(setTeam); }","typeGuard":"const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.length > 0;","tryCatchPattern":"try { const team = await agentTeamApi.get(teamId); }\ncatch (e) { if (String(e.message).includes('teamId is required')) showEmptyState(); else throw e; }","preventionTips":["Initialize id state to null, not '', so falsy checks are natural","Gate data-fetch effects on the id being truthy","Type route params as string | undefined and check before use"],"tags":["validation","agent-teams","required-field"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}