{"record":{"id":"d380db9acf9e39c6","repo":"flowable/flowable-engine","slug":"user-is-not-part-of-group","errorCode":null,"errorMessage":"User '' is not part of group ''.","messagePattern":"User '' is not part of group ''\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/GroupMembershipResource.java","lineNumber":51,"sourceCode":" */\n@RestController\n@Api(tags = { \"Groups\" }, authorizations = { @Authorization(value = \"basicAuth\") })\npublic class GroupMembershipResource extends BaseGroupResource {\n\n    @ApiOperation(value = \"Delete a member from a group\", tags = { \"Groups\" }, code = 204)\n    @ApiResponses(value = {\n            @ApiResponse(code = 204, message = \"Indicates the group was found and the member has been deleted. The response body is left empty intentionally.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested group was not found or that the user is not a member of the group. The status description contains additional information about the error.\")\n    })\n    @DeleteMapping(\"/identity/groups/{groupId}/members/{userId}\")\n    @ResponseStatus(HttpStatus.NO_CONTENT)\n    public void deleteMembership(@ApiParam(name = \"groupId\") @PathVariable(\"groupId\") String groupId, @ApiParam(name = \"userId\") @PathVariable(\"userId\") String userId) {\n\n        Group group = getGroupFromRequest(groupId);\n\n        // Check if user is not a member of group since API does not return typed exception\n        if (identityService.createUserQuery().memberOfGroup(group.getId()).userId(userId).count() != 1) {\n            throw new FlowableObjectNotFoundException(\"User '\" + userId + \"' is not part of group '\" + group.getId() + \"'.\", null);\n        }\n\n        identityService.deleteMembership(userId, group.getId());\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/identity/GroupMembershipResource.java#L33-L57","documentation":"GroupMembershipResource.deleteMembership verifies the user is actually a member of the group via createUserQuery().memberOfGroup(groupId).userId(userId).count() before deleting. When the count is not 1, it throws FlowableObjectNotFoundException (HTTP 404) because the membership does not exist, even though both user and group may individually exist.","triggerScenarios":"DELETE /identity/groups/{groupId}/members/{userId} where the user is not a member of the group (or the group does not exist, since getGroupFromRequest runs first).","commonSituations":"De-provisioning scripts removing memberships that were never created; user already removed by a concurrent request; wrong groupId/userId pairing (member of another group); case-sensitivity mismatch in the user id.","solutions":["Verify the membership exists before deleting: GET /identity/groups/{groupId}/members and check the userId.","Treat 404 from this endpoint as 'already removed' and continue in cleanup scripts.","Confirm the exact groupId/userId spelling and casing."],"exampleFix":"// before\nclient.delete(\"/identity/groups/sales/members/\" + userId); // 404 if not a member\n// after\nif (fetchMemberIds(\"sales\").contains(userId)) {\n    client.delete(\"/identity/groups/sales/members/\" + userId);\n}","handlingStrategy":"try-catch","validationCode":"boolean isMember = client.list(\"/identity/groups/\" + groupId + \"/members\").stream()\n    .anyMatch(m -> userId.equals(m.getUserId()));","typeGuard":null,"tryCatchPattern":"try {\n    client.delete(\"/identity/groups/\" + groupId + \"/members/\" + userId);\n} catch (HttpClientErrorException e) {\n    if (e.getStatusCode() == HttpStatus.NOT_FOUND) {\n        log.info(\"Membership {}#{} already absent\", groupId, userId);\n    } else throw e;\n}","preventionTips":["Check membership before removal in cleanup scripts.","Treat 404 as idempotent success on deletes.","Verify groupId/userId spelling and casing."],"tags":["rest-api","membership","not-found","delete"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}