flowable/flowable-engine · error · FlowableIllegalArgumentException

caseInstance tenant id is null

Error message

caseInstance tenant id is null

What it means

HistoricCaseInstanceQueryImpl.caseInstanceTenantId(String) throws FlowableIllegalArgumentException with message 'caseInstance tenant id is null' when tenantId is null. Tenant id filters restrict results to one tenant; null is not accepted — to ignore tenancy, simply do not call this method.

Solutions

  1. Pass a non-null tenant id string matching the tenant of the case instances.
  2. Omit the tenant filter entirely when querying across tenants (no 'null tenant' concept in the query API).
  3. If an empty tenant is valid in your model, use caseInstanceTenantIdLike("") semantics carefully or filter client-side — never pass null.

Example fix

// before
query.caseInstanceTenantId(tenantContext.getTenantId()); // may be null
// after
String tenantId = tenantContext.getTenantId();
if (tenantId != null) {
    query.caseInstanceTenantId(tenantId);
}
Defensive patterns

Strategy: validation

Validate before calling

String tenantId = tenantContext.getTenantId();
if (tenantId != null) {
    query.caseInstanceTenantId(tenantId);
} // else: query without tenant restriction

Type guard

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

Try / catch

try {
    query.caseInstanceTenantId(tenantId);
} catch (FlowableIllegalArgumentException e) {
    throw new IllegalStateException("Tenant context not initialized", e);
}

Prevention

When it happens

Trigger: Calling caseInstanceTenantId(null) directly or inside an or() block, typically when the tenant was resolved from a nullable context (user profile, request header, tenant context holder).

Common situations: Multi-tenant apps where the tenant resolver returns null for unauthenticated/system calls; copying tenant handling from caseInstanceTenantIdLike variants; wiring the tenant id from a config key that is missing.

Related errors


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

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java:832

    }

    @Override
    public HistoricCaseInstanceQuery caseInstanceReferenceType(String referenceType) {
        if (referenceType == null) {
            throw new FlowableIllegalArgumentException("referenceType is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.referenceType = referenceType;
        } else {
            this.referenceType = referenceType;
        }
        return this;
    }

    @Override
    public HistoricCaseInstanceQueryImpl caseInstanceTenantId(String tenantId) {
        if (tenantId == null) {
            throw new FlowableIllegalArgumentException("caseInstance tenant id is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.tenantId = tenantId;
        } else {
            this.tenantId = tenantId;
        }
        return this;
    }
    
    @Override
    public HistoricCaseInstanceQueryImpl caseInstanceTenantIdLike(String tenantIdLike) {
        if (tenantIdLike == null) {
            throw new FlowableIllegalArgumentException("caseInstance tenant id is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.tenantIdLike = tenantIdLike;
        } else {
            this.tenantIdLike = tenantIdLike;

View on GitHub (pinned to d6d39ce1c6)