flowable/flowable-engine · error · FlowableIllegalArgumentException

userId is null

Error message

userId is null

What it means

GetUserPictureCmd fetches a user's Picture by userId. Because a null userId cannot match any user row, the command rejects it up front with FlowableIllegalArgumentException before issuing the identity query.

Source

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

import org.flowable.idm.api.User;
import org.flowable.idm.engine.impl.util.CommandContextUtil;

/**
 * @author Tom Baeyens
 */
public class GetUserPictureCmd implements Command<Picture>, Serializable {

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

    public GetUserPictureCmd(String userId) {
        this.userId = userId;
    }

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

        User user = CommandContextUtil.getIdmEngineConfiguration().getIdmIdentityService()
                .createUserQuery().userId(userId)
                .singleResult();

        if (user == null) {
            throw new FlowableObjectNotFoundException("user " + userId + " doesn't exist", User.class);
        }

        return CommandContextUtil.getUserEntityManager(commandContext).getUserPicture(user);
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Pass a non-null userId; verify the variable or parameter actually holds the id
  2. Skip the call when userId is null instead of delegating to the engine
  3. Handle FlowableIllegalArgumentException where null userIds are expected

Example fix

// before
Picture picture = identityService.getUserPicture(userId);
// after
Picture picture = userId != null ? identityService.getUserPicture(userId) : null;
Defensive patterns

Strategy: validation

Validate before calling

if (userId == null || userId.isEmpty()) throw new IllegalArgumentException("userId is required");

Type guard

boolean hasUserId(String userId) { return userId != null && !userId.trim().isEmpty(); }

Try / catch

try { Picture p = identityService.getUserPicture(userId); } catch (FlowableIllegalArgumentException e) { log.warn("userId missing, no picture"); }

Prevention

When it happens

Trigger: Calling identityService.getUserPicture(null) or executing new GetUserPictureCmd(null) when the Picture was never set or the userId variable was never populated.

Common situations: Code that reads a userId from a task/process variable, authentication context, or request parameter that is absent at runtime; calling getUserPicture before creating the user.

Related errors


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