flowable/flowable-engine · error · FlowableIllegalArgumentException

userId is null

Error message

userId is null

What it means

DeleteMembershipCmd.execute() validates both userId and groupId before removing the membership; this error is raised when userId is null. Membership is keyed by the (userId, groupId) pair, so neither component may be null.

Solutions

  1. Pass a non-null userId (and groupId) to IdentityService.deleteMembership().
  2. Load the user first and use its verified id rather than an optional/nulled field.
  3. Guard the call: skip membership deletion when userId is null and log the condition instead.
  4. Catch FlowableIllegalArgumentException to translate it into an application validation error.

Example fix

// before
identityService.deleteMembership(userId, groupId); // userId may be null

// after
if (userId != null && groupId != null) {
    identityService.deleteMembership(userId, groupId);
}
Defensive patterns

Strategy: validation

Validate before calling

if (userId == null) {
    throw new IllegalArgumentException("userId must be provided before deleting a membership");
}
if (groupId == null) {
    throw new IllegalArgumentException("groupId must be provided before deleting a membership");
}

Type guard

boolean hasValidMembershipKey(String userId, String groupId) {
    return userId != null && groupId != null;
}

Try / catch

try {
    identityService.deleteMembership(userId, groupId);
} catch (FlowableIllegalArgumentException e) {
    if (e.getMessage().contains("is null")) {
        throw new InvalidRequestException("Both userId and groupId are required to delete a membership");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling IdentityService.deleteMembership(null, groupId), or constructing DeleteMembershipCmd with a null userId, e.g. when removing a user's group links during user deletion where the user object/id was never loaded.

Common situations: User-deletion cleanup code where the user id variable is null because the user was already deleted; REST endpoints accepting optional userId; copy-paste between deleteMembership calls swapping or dropping arguments.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/faddc370c7b30a88. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/DeleteMembershipCmd.java:39

/**
 * @author Tom Baeyens
 */
public class DeleteMembershipCmd implements Command<Void>, Serializable {

    private static final long serialVersionUID = 1L;
    String userId;
    String groupId;

    public DeleteMembershipCmd(String userId, String groupId) {
        this.userId = userId;
        this.groupId = groupId;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (userId == null) {
            throw new FlowableIllegalArgumentException("userId is null");
        }
        if (groupId == null) {
            throw new FlowableIllegalArgumentException("groupId is null");
        }

        CommandContextUtil.getMembershipEntityManager(commandContext).deleteMembership(userId, groupId);

        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)