flowable/flowable-engine · error · FlowableIllegalArgumentException
userId is null
Error message
userId is null
What it means
CreateMembershipCmd.execute(CommandContext) throws FlowableIllegalArgumentException when its userId field is null at execution time. A membership links a user to a group, and creating one without a user is invalid. Note the constructor only validates groupId here, so a null userId surfaces when the command runs.
Source
Thrown at modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreateMembershipCmd.java:40
/**
* @author Tom Baeyens
*/
public class CreateMembershipCmd implements Command<Object>, Serializable {
private static final long serialVersionUID = 1L;
String userId;
String groupId;
public CreateMembershipCmd(String userId, String groupId) {
this.userId = userId;
this.groupId = groupId;
}
@Override
public Object execute(CommandContext commandContext) {
if (userId == null) {
throw new FlowableIllegalArgumentException("userId is null");
}
if (groupId == null) {
throw new FlowableIllegalArgumentException("groupId is null");
}
CommandContextUtil.getMembershipEntityManager(commandContext).createMembership(userId, groupId);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Pass a non-null userId that references an existing user.
- Create the user first (identityService.newUser/saveUser) before creating the membership.
- Validate both ids before calling createMembership.
Example fix
// before
identityService.createMembership(user.getId(), group.getId()); // user.getId() null
// after
if (user.getId() != null) {
identityService.createMembership(user.getId(), group.getId());
} else {
identityService.saveUser(user); // persist to obtain the id first
identityService.createMembership(user.getId(), group.getId());
} Defensive patterns
Strategy: validation
Validate before calling
if (userId != null && groupId != null) { identityService.createMembership(userId, groupId); } Type guard
boolean canCreateMembership(String userId, String groupId) { return userId != null && groupId != null; } Try / catch
try { identityService.createMembership(userId, groupId); } catch (FlowableIllegalArgumentException e) { log.error("Membership needs non-null userId and groupId", e); } Prevention
- Persist the user first so its id is non-null
- Null-check both ids before creating memberships
- Validate source data in sync jobs before issuing IDM calls
When it happens
Trigger: Calling identityService.createMembership(null, groupId) — the command executes and fails its userId check.
Common situations: Bulk user/group synchronization jobs where a user record failed to load or the id field is null in the source data.
Related errors
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/f052a28da9e57e8a.
Report an issue: GitHub.