{"record":{"id":"65f4ab220e4c0be2","repo":"FlowiseAI/Flowise","slug":"user-is-not-a-member-of-this-chat","errorCode":null,"errorMessage":"User is not a member of this chat","messagePattern":"User is not a member of this chat","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/components/nodes/tools/MicrosoftTeams/core.ts","lineNumber":894,"sourceCode":"        super({ ...toolInput, accessToken: args.accessToken, defaultParams: args.defaultParams })\n    }\n\n    protected async _call(arg: any): Promise<string> {\n        const params = { ...arg, ...this.defaultParams }\n        const { chatId, userId } = params\n\n        if (!chatId || !userId) {\n            throw new Error('Both Chat ID and User ID are required')\n        }\n\n        try {\n            // First get the membership ID\n            const membersEndpoint = `/chats/${chatId}/members`\n            const membersResult = await this.makeTeamsRequest(membersEndpoint)\n\n            const member = membersResult.value?.find((m: any) => m.userId === userId)\n            if (!member) {\n                throw new Error('User is not a member of this chat')\n            }\n\n            const endpoint = `/chats/${chatId}/members/${member.id}`\n            await this.makeTeamsRequest(endpoint, 'DELETE')\n\n            return this.formatResponse(\n                {\n                    success: true,\n                    message: 'Member removed from chat successfully'\n                },\n                params\n            )\n        } catch (error) {\n            return this.formatResponse(`Error removing chat member: ${error}`, params)\n        }\n    }\n}\n","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/MicrosoftTeams/core.ts#L876-L912","documentation":"Thrown by RemoveChatMember after it successfully lists the chat's members at GET /chats/{chatId}/members but finds no member whose userId matches the supplied userId. This is a conditional runtime error indicating the user is not currently a participant in the chat, so there is no membership to delete.","triggerScenarios":"Calling RemoveChatMember for a user who already left or was never added; using a userId that belongs to a different tenant; the chat membership list is stale because the user was removed by another process; case/format mismatch between the supplied userId and the userId field returned by Graph.","commonSituations":"Idempotency issue: an agent retries a removal that already succeeded; cross-tenant confusion where a userId from tenant A is used against a chat in tenant B; the agent picked a stale userId from a cached member list.","solutions":["First call a list-members tool to confirm the user is present before attempting removal.","Treat this error as benign if the goal is just to ensure the user is gone (idempotent removal).","Verify the userId matches the tenant of the chat (same Azure AD object ID format).","Refresh any cached member list before retrying."],"exampleFix":"// before: blind removal\nawait removeMemberTool._call({ chatId, userId })\n// after: check membership first\nconst members = await listMembersTool._call({ chatId })\nconst isMember = JSON.parse(members).some(m => m.userId === userId)\nif (isMember) await removeMemberTool._call({ chatId, userId })","handlingStrategy":"validation","validationCode":"async function isChatMember(listTool: any, chatId: string, userId: string): Promise<boolean> {\n  const res = await listTool.call({ chatId })\n  const data = JSON.parse(res)\n  return Array.isArray(data.value) && data.value.some((m: any) => m.userId === userId)\n}","typeGuard":"null","tryCatchPattern":"try {\n  await removeMemberTool.call({ chatId, userId })\n} catch (e) {\n  if (e instanceof Error && e.message === 'User is not a member of this chat') {\n    // already removed: treat as success (idempotent)\n  } else throw e\n}","preventionTips":["Treat removal as idempotent: a 'not a member' result is success.","Refresh the member list before retrying.","Confirm the userId belongs to the same tenant as the chat."],"tags":["microsoft-teams","graph-api","conditional","state-mismatch"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}