flowable/flowable-engine · error · FlowableIllegalArgumentException

Provided user id is null

Error message

Provided user id is null

What it means

TokenQueryImpl.userId(String) filters tokens by the owning user's id. A null argument is rejected immediately with FlowableIllegalArgumentException since null cannot be used as an equality criterion in the generated SQL and would silently change query semantics. The library throws at query-construction time to fail fast.

Solutions

  1. Verify the user id is resolved before building the query (authenticate the caller first).
  2. Conditionally add the criterion only for non-null ids, or throw your own clearer exception when the id is required.
  3. If you meant 'no such user', check user existence first rather than querying tokens with a null id.

Example fix

// before
String userId = securityContext.getUserId(); // may be null
List<Token> tokens = identityService.createTokenQuery().userId(userId).list();

// after
String userId = securityContext.getUserId();
if (userId == null) {
    throw new AuthenticationException("User must be authenticated");
}
List<Token> tokens = identityService.createTokenQuery().userId(userId).list();
Defensive patterns

Strategy: validation

Validate before calling

if (userId == null || userId.isEmpty()) {
    throw new IllegalStateException("Authenticated user id required for token lookup");
}
identityService.createTokenQuery().userId(userId);

Type guard

boolean hasUserId(Principal p) { return p != null && p.getName() != null; }

Try / catch

try {
    query.userId(userId);
} catch (FlowableIllegalArgumentException e) {
    throw new AuthenticationException("Cannot look up tokens without a user id", e);
}

Prevention

When it happens

Trigger: Calling TokenQuery.userId(null), typically identityService.createTokenQuery().userId(currentUserId) where currentUserId is null (e.g. unauthenticated request).

Common situations: Using a security-context user id that is null for anonymous sessions; a variable not yet assigned before query building; passing a lookup result that returned null for an unknown user.

Related errors


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

Appendix: source

Thrown at modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/TokenQueryImpl.java:155

            throw new FlowableIllegalArgumentException("Provided user agent is null");
        }
        this.userAgent = userAgent;
        return this;
    }

    @Override
    public TokenQuery userAgentLike(String userAgentLike) {
        if (userAgentLike == null) {
            throw new FlowableIllegalArgumentException("Provided userAgentLike is null");
        }
        this.userAgentLike = userAgentLike;
        return this;
    }

    @Override
    public TokenQuery userId(String userId) {
        if (userId == null) {
            throw new FlowableIllegalArgumentException("Provided user id is null");
        }
        this.userId = userId;
        return this;
    }

    @Override
    public TokenQuery userIdLike(String userIdLike) {
        if (userIdLike == null) {
            throw new FlowableIllegalArgumentException("Provided userIdLike is null");
        }
        this.userIdLike = userIdLike;
        return this;
    }

    @Override
    public TokenQuery tokenData(String tokenData) {
        if (tokenData == null) {
            throw new FlowableIllegalArgumentException("Provided token data is null");

View on GitHub (pinned to d6d39ce1c6)