flowable/flowable-engine · error · FlowableIllegalArgumentException

caseDefinition tenantId is null

Error message

caseDefinition tenantId is null

What it means

caseDefinitionTenantId in CaseDefinitionQueryImpl throws FlowableIllegalArgumentException with "caseDefinition tenantId is null" when passed a null tenantId. Multi-tenancy filters must be explicit strings; to query across tenants simply omit the filter rather than passing null.

Solutions

  1. Null-check the tenantId and only call caseDefinitionTenantId when non-null.
  2. Ensure tenant resolution (header/context/config) is in place and returns a real tenant id before building the query.
  3. If all tenants should be searched, drop the tenant filter call entirely.

Example fix

// before
query.caseDefinitionTenantId(tenantContext.getCurrentTenantId());

// after
String tenantId = tenantContext.getCurrentTenantId();
if (tenantId != null) {
    query.caseDefinitionTenantId(tenantId);
}
Defensive patterns

Strategy: validation

Validate before calling

String tenantId = tenantContext.getCurrentTenantId();
if (tenantId != null && !tenantId.isEmpty()) {
    query.caseDefinitionTenantId(tenantId);
}

Type guard

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

Try / catch

try {
    query.caseDefinitionTenantId(tenantId);
} catch (FlowableIllegalArgumentException e) {
    if (!e.getMessage().contains("tenantId is null")) throw e;
    query = repositoryService.createCaseDefinitionQuery(); // unfiltered fallback
}

Prevention

When it happens

Trigger: Calling caseDefinitionTenantId(null) — typically when the tenant id is taken from an unauthenticated request context, a missing header (e.g. X-Tenant-Id), or a Map lookup that returned null.

Common situations: TenantContext not populated because tenant resolution middleware did not run; single-tenant deployments where tenant id was never configured; passing the result of TenantProvider.getTenant() that returns null for the default tenant.

Related errors


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

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CaseDefinitionQueryImpl.java:264

    protected void checkVersion(Integer version) {
        if (version == null) {
            throw new FlowableIllegalArgumentException("version is null");
        } else if (version <= 0) {
            throw new FlowableIllegalArgumentException("version must be positive");
        }
    }

    @Override
    public CaseDefinitionQueryImpl latestVersion() {
        this.latest = true;
        return this;
    }

    @Override
    public CaseDefinitionQuery caseDefinitionTenantId(String tenantId) {
        if (tenantId == null) {
            throw new FlowableIllegalArgumentException("caseDefinition tenantId is null");
        }
        this.tenantId = tenantId;
        return this;
    }

    @Override
    public CaseDefinitionQuery caseDefinitionTenantIdLike(String tenantIdLike) {
        if (tenantIdLike == null) {
            throw new FlowableIllegalArgumentException("case definition tenantId is null");
        }
        this.tenantIdLike = tenantIdLike;
        return this;
    }

    @Override
    public CaseDefinitionQuery caseDefinitionWithoutTenantId() {
        this.withoutTenantId = true;
        return this;

View on GitHub (pinned to d6d39ce1c6)