flowable/flowable-engine · error · FlowableIllegalArgumentException

Provided tokenDateBefore is null

Error message

Provided tokenDateBefore is null

What it means

Flowable's TokenQueryImpl.tokenDateBefore(Date tokenDateBefore) throws FlowableIllegalArgumentException when the argument is null. This upper-bound date criterion must be non-null to be translated into a SQL comparison. It is checked eagerly in the fluent API.

Solutions

  1. Compute the cutoff date safely and skip the criterion if it cannot be computed
  2. Apply the filter only when non-null: if (until != null) query.tokenDateBefore(until);
  3. Default the cutoff to a sensible value like new Date() instead of null

Example fix

// before
TokenQuery query = identityService.createTokenQuery().tokenDateBefore(cutoff);
// after
TokenQuery query = identityService.createTokenQuery();
if (cutoff != null) {
    query.tokenDateBefore(cutoff);
}
Defensive patterns

Strategy: validation

Validate before calling

if (cutoff == null) { throw new IllegalArgumentException("cutoff must not be null before tokenDateBefore()"); }

Type guard

boolean hasCutoff(Date cutoff) { return cutoff != null; }

Try / catch

try { query.tokenDateBefore(cutoff); } catch (FlowableIllegalArgumentException e) { log.warn("Invalid token query: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Calling tokenDateBefore(null) on a TokenQuery, commonly when an 'until' date parameter was optional and null was passed unconditionally, or a date computation (e.g. Calendar operations) produced null.

Common situations: Cleanup jobs finding tokens older than a cutoff where the cutoff calculation failed; REST endpoints with optional until/from filters; scheduler code where a configured date was not resolved.

Related errors


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

Appendix: source

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

            throw new FlowableIllegalArgumentException("Provided token value is null");
        }
        this.tokenValue = tokenValue;
        return this;
    }

    @Override
    public TokenQuery tokenDate(Date tokenDate) {
        if (tokenDate == null) {
            throw new FlowableIllegalArgumentException("Provided token date is null");
        }
        this.tokenDate = tokenDate;
        return this;
    }

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

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

    @Override
    public TokenQuery ipAddress(String ipAddress) {
        if (ipAddress == null) {
            throw new FlowableIllegalArgumentException("Provided ip address is null");

View on GitHub (pinned to d6d39ce1c6)