flowable/flowable-engine · error · FlowableIllegalArgumentException

tenant id is null

Error message

tenant id is null

What it means

MilestoneInstanceQueryImpl.milestoneInstanceTenantId(String) filters milestone instances by tenant. A null tenant id is treated as a programming error rather than an absent filter, so FlowableIllegalArgumentException is thrown; use milestoneInstanceTenantIdWithoutTenantCheck()/ignoreTenant filtering instead of passing null.

Source

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

        return this;
    }

    @Override
    public MilestoneInstanceQuery milestoneInstanceReachedBefore(Date reachedBefore) {
        this.reachedBefore = reachedBefore;
        return this;
    }

    @Override
    public MilestoneInstanceQuery milestoneInstanceReachedAfter(Date reachedAfter) {
        this.reachedAfter = reachedAfter;
        return this;
    }
    
    @Override
    public MilestoneInstanceQuery milestoneInstanceTenantId(String tenantId) {
        if (tenantId == null) {
            throw new FlowableIllegalArgumentException("tenant id is null");
        }
        this.tenantId = tenantId;
        return this;
    }

    @Override
    public MilestoneInstanceQuery milestoneInstanceTenantIdLike(String tenantIdLike) {
        if (tenantIdLike == null) {
            throw new FlowableIllegalArgumentException("tenant id is null");
        }
        this.tenantIdLike = tenantIdLike;
        return this;
    }
    
    @Override
    public MilestoneInstanceQuery milestoneInstanceWithoutTenantId() {
        this.withoutTenantId = true;
        return this;

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Only call milestoneInstanceTenantId when the tenant id is non-null; skip the filter otherwise
  2. Fix the tenant provider so it always supplies a valid tenant id
  3. If you want milestone instances regardless of tenant, do not set a tenant filter at all

Example fix

// before
query.milestoneInstanceTenantId(tenantId); // NPE-style IAE when null
// after
if (tenantId != null) {
    query.milestoneInstanceTenantId(tenantId);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (tenantId != null) { query.milestoneInstanceTenantId(tenantId); }

Type guard

boolean hasTenant(String t) { return t != null && !t.trim().isEmpty(); }

Try / catch

try { query.milestoneInstanceTenantId(tenantId); } catch (FlowableIllegalArgumentException e) { query = runtimeService.createMilestoneInstanceQuery(); }

Prevention

When it happens

Trigger: Calling milestoneInstanceTenantId(null) on a milestone instance query, typically with a tenant id sourced from a nullable variable or request parameter.

Common situations: Tenant context not set in a multi-tenant app; passing the result of a lookup that returned null; attempting to 'clear' a tenant filter by passing null.

Related errors


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