{"record":{"id":"3a3b80ca8d60bc7d","repo":"flowable/flowable-engine","slug":"groupid-is-null-3a3b80","errorCode":null,"errorMessage":"groupId is null","messagePattern":"groupId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreateMembershipCmd.java","lineNumber":43,"sourceCode":"public class CreateMembershipCmd implements Command<Object>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    String userId;\n    String groupId;\n\n    public CreateMembershipCmd(String userId, String groupId) {\n        this.userId = userId;\n        this.groupId = groupId;\n    }\n\n    @Override\n    public Object execute(CommandContext commandContext) {\n        if (userId == null) {\n            throw new FlowableIllegalArgumentException(\"userId is null\");\n        }\n        if (groupId == null) {\n            throw new FlowableIllegalArgumentException(\"groupId is null\");\n        }\n        CommandContextUtil.getMembershipEntityManager(commandContext).createMembership(userId, groupId);\n        return null;\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":49,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreateMembershipCmd.java#L25-L49","documentation":"CreateMembershipCmd.execute(CommandContext) throws FlowableIllegalArgumentException when its groupId field is null at execution time. Memberships must reference an existing group; a null group id is rejected before touching the entity manager. The constructor validates userId but this check runs when the command executes.","triggerScenarios":"Calling identityService.createMembership(userId, null) — the command executes and fails its groupId check.","commonSituations":"Assignment code resolving the target group from a process variable or LDAP attribute that is missing, yielding null.","solutions":["Pass a non-null groupId that references an existing group.","Create the group first (identityService.newGroup/saveGroup) if it doesn't exist.","Check group.getId() for null before calling createMembership."],"exampleFix":"// before\nidentityService.createMembership(userId, group.getId()); // group.getId() null\n// after\nif (group.getId() == null) {\n    identityService.saveGroup(group);\n}\nidentityService.createMembership(userId, group.getId());","handlingStrategy":"validation","validationCode":"if (userId != null && groupId != null) { identityService.createMembership(userId, groupId); }","typeGuard":"boolean canCreateMembership(String userId, String groupId) { return userId != null && groupId != null; }","tryCatchPattern":"try { identityService.createMembership(userId, groupId); } catch (FlowableIllegalArgumentException e) { log.error(\"Membership needs non-null userId and groupId\", e); }","preventionTips":["Create/save the group first so getId() is non-null","Null-check group.getId() before membership creation","Fail loudly when a required group cannot be resolved instead of passing null"],"tags":["flowable","idm","null-argument","membership","group"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}