{"record":{"id":"0e6400fad9466ada","repo":"immich-app/immich","slug":"cannot-request-to-join-your-own-cluster-group","errorCode":null,"errorMessage":"Cannot request to join your own cluster group","messagePattern":"Cannot request to join your own cluster group","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"server/src/services/cluster-group.service.ts","lineNumber":43,"sourceCode":"    return requests.map((request) => mapClusterGroupRequest(request));\n  }\n\n  async getUsers(auth: AuthDto, clusterGroupId: string): Promise<UserResponseDto[]> {\n    await this.requireAccess({ auth, permission: Permission.ClusterGroupRead, ids: [clusterGroupId] });\n\n    const users = await this.clusterGroupRepository.getUsers({ clusterGroupId, userId: auth.user.id });\n    return users.map((user) => mapUser(user));\n  }\n\n  async createRequest(\n    auth: AuthDto,\n    clusterGroupId: string,\n    { userId }: ClusterGroupRequestCreateDto,\n  ): Promise<MaybeDuplicate<ClusterGroupRequestResponseDto>> {\n    await this.requireAccess({ auth, permission: Permission.ClusterGroupRequestCreate, ids: [clusterGroupId] });\n\n    if (userId === auth.user.id) {\n      throw new BadRequestException('Cannot request to join your own cluster group');\n    }\n\n    await findOrFail(() => this.userRepository.get(userId, {}), 'User');\n\n    const request = await findOrFail(\n      () => this.clusterGroupRepository.createRequest({ clusterGroupId, userId }),\n      'Request',\n    );\n\n    if (request.isInserted) {\n      await this.eventRepository.emit('ClusterGroupRequest', { clusterGroupId, userId, senderName: auth.user.name });\n    }\n\n    return { duplicate: !request.isInserted, value: mapClusterGroupRequest(request) };\n  }\n\n  async acceptRequest(auth: AuthDto, id: string): Promise<void> {\n    await this.requireAccess({ auth, permission: Permission.ClusterGroupRequestRead, ids: [id] });","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/cluster-group.service.ts#L25-L61","documentation":"When creating a cluster-group join request, the requested userId is compared against the authenticated user's id. If they match, the caller is trying to request membership in a group they already belong to, which is nonsensical, so a BadRequestException is thrown. The target user must always be someone else.","triggerScenarios":"POSTing a cluster group join request where the DTO userId equals auth.user.id — i.e. an admin invites themselves into their own cluster group.","commonSituations":"UI bug sending the current user's id as the invitee; scripting the join-request API with your own userId instead of another member's; testing with a single account.","solutions":["Pass the userId of a different user (the person who wants to join), not your own.","In the client, disable/hide the 'request to join' action for the caller's own group.","If the user should switch groups, have them use the leave/merge flow rather than a self join-request."],"exampleFix":"// before\nawait api.createClusterGroupRequest(groupId, { userId: auth.user.id }); // self-request → error\n// after\nawait api.createClusterGroupRequest(groupId, { userId: otherUserId });","handlingStrategy":"validation","validationCode":"// Never send the caller's own userId in a join request\nif (requestBody.userId === currentUserId) {\n  throw new Error('Cannot request to join your own cluster group');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In UI, hide the join-request action on the caller's own group.","Validate invitee id != current user id in client forms before submit.","Use leave/merge endpoints for self group changes, not join requests."],"tags":["cluster-group","bad-request","validation","self-reference"],"backgroundTag":"invalid-argument-value","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}