flowable/flowable-engine · error · FlowableIllegalArgumentException

Provided tenant id is null

Error message

Provided tenant id is null

What it means

HistoryJobQuery.jobTenantId(String) throws FlowableIllegalArgumentException when tenantId is null. Tenant filtering is a common multi-tenancy requirement, and Flowable validates that the tenant id passed to this method is non-null rather than issuing a query with a null tenant criterion.

Solutions

  1. Only call jobTenantId() when a tenant id is known; otherwise omit it to query across tenants
  2. Use jobTenantIdLike() if partial matching is intended (also requires non-null)
  3. Guard: if (tenantId != null) query.jobTenantId(tenantId)
  4. Fix tenant resolution (auth/context setup) so the id is always populated for tenant-scoped requests

Example fix

// before
query.jobTenantId(tenantId); // may be null
// after
if (tenantId != null) {
    query.jobTenantId(tenantId);
}
Defensive patterns

Strategy: validation

Validate before calling

if (tenantId == null) { throw new IllegalArgumentException("tenantId is required for tenant-scoped queries"); }
historyJobQuery.jobTenantId(tenantId);

Type guard

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

Try / catch

try {
    query.jobTenantId(tenantId);
} catch (FlowableIllegalArgumentException e) {
    log.warn("tenant filter skipped: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling historyJobQuery.jobTenantId(null), directly or in an or() block, e.g. when the tenant id comes from an unauthenticated context, a missing header/variable, or an entity whose tenant was never set.

Common situations: Multi-tenant applications where the tenant resolver returned null (missing tenant header, anonymous request); passing a nullable tenant field from a process/entity; generic query builders that always call jobTenantId().

Related errors


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

Appendix: source

Thrown at modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/HistoryJobQueryImpl.java:151

    }

    @Override
    public HistoryJobQuery scopeType(String scopeType) {
        if (scopeType == null) {
            throw new FlowableIllegalArgumentException("Provided scope type is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.scopeType = scopeType;
        } else {
            this.scopeType = scopeType;
        }
        return this;
    }

    @Override
    public HistoryJobQuery jobTenantId(String tenantId) {
        if (tenantId == null) {
            throw new FlowableIllegalArgumentException("Provided tenant id is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.tenantId = tenantId;
        } else {
            this.tenantId = tenantId;
        }
        return this;
    }

    @Override
    public HistoryJobQuery jobTenantIdLike(String tenantIdLike) {
        if (tenantIdLike == null) {
            throw new FlowableIllegalArgumentException("Provided tenant id is null");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.tenantIdLike = tenantIdLike;
        } else {
            this.tenantIdLike = tenantIdLike;

View on GitHub (pinned to d6d39ce1c6)