flowable/flowable-engine · error · FlowableIllegalArgumentException

terminatedAfter is null

Error message

terminatedAfter is null

What it means

Flowable throws FlowableIllegalArgumentException when planItemInstanceTerminatedAfter(Date) is called with a null Date. Criteria methods on the plan item instance query validate their argument up front, so a null timestamp fails immediately instead of corrupting the generated query. Leaving the criterion unapplied is done by not calling the method.

Solutions

  1. Compute a valid non-null Date before invoking the method.
  2. Guard the call with a null check and omit the criterion when absent.
  3. Parse and validate any string input into a Date with explicit failure handling.
  4. Catch FlowableIllegalArgumentException around query building to convert it into a user-facing validation message.

Example fix

// before
query.planItemInstanceTerminatedAfter(terminatedAfter); // possibly null
// after
if (terminatedAfter != null) {
    query.planItemInstanceTerminatedAfter(terminatedAfter);
}
Defensive patterns

Strategy: validation

Validate before calling

if (terminatedAfter == null) {
    throw new IllegalArgumentException("terminatedAfter must be non-null; omit the filter instead");
}
query.planItemInstanceTerminatedAfter(terminatedAfter);

Type guard

boolean hasTerminatedAfter = (terminatedAfter != null);

Try / catch

try {
    query.planItemInstanceTerminatedAfter(terminatedAfter);
} catch (FlowableIllegalArgumentException e) {
    if (e.getMessage().contains("terminatedAfter")) {
        throw new BadRequestException("terminatedAfter date filter must not be null");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling createPlanItemInstanceQuery().planItemInstanceTerminatedAfter(null), typically when the after-date comes from an optional parameter or uninitialized field.

Common situations: Empty 'terminatedAfter' input in a filter UI; absent JSON field; a null result from Calendar.getTime() on an unset Calendar.

Related errors


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

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java:584

    }

    @Override
    public PlanItemInstanceQuery planItemInstanceTerminatedBefore(Date terminatedBefore) {
        if (terminatedBefore == null) {
            throw new FlowableIllegalArgumentException("terminatedBefore is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.terminatedBefore = terminatedBefore;
        } else {
            this.terminatedBefore = terminatedBefore;
        }
        return this;
    }

    @Override
    public PlanItemInstanceQuery planItemInstanceTerminatedAfter(Date terminatedAfter) {
        if (terminatedAfter == null) {
            throw new FlowableIllegalArgumentException("terminatedAfter is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.terminatedAfter = terminatedAfter;
        } else {
            this.terminatedAfter = terminatedAfter;
        }
        return this;
    }

    @Override
    public PlanItemInstanceQuery planItemInstanceFailedBefore(Date failedBefore) {
        if (failedBefore == null) {
            throw new FlowableIllegalArgumentException("failedBefore is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.failedBefore = failedBefore;
        } else {
            this.failedBefore = failedBefore;

View on GitHub (pinned to d6d39ce1c6)