flowable/flowable-engine · error · FlowableIllegalArgumentException

tenantId is null

Error message

tenantId is null

What it means

BatchPartQueryImpl.tenantId() throws FlowableIllegalArgumentException when the tenantId argument is null. Flowable treats tenant filtering as an explicit exact-match operation; to query across tenants you omit the call, you never pass null.

Solutions

  1. Pass a non-null tenant id string (use empty string "" if you mean the default tenant)
  2. Omit .tenantId(...) entirely when querying across all tenants
  3. Check the tenant context/resolver before building the query

Example fix

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

Strategy: validation

Validate before calling

String tenantId = tenantContext.getCurrentTenantId();
if (tenantId == null) {
    throw new IllegalStateException("No tenant in context; cannot build tenant-scoped batch part query");
}
query.tenantId(tenantId);

Type guard

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

Try / catch

try {
    query.tenantId(tenantId);
} catch (FlowableIllegalArgumentException e) {
    // tenant context lost; run unfiltered or fail with a clearer error
}

Prevention

When it happens

Trigger: Calling batchPartQuery().tenantId(null), or forwarding a tenant id from a security/context holder that has no tenant set (single-tenant deployments).

Common situations: Multi-tenant code paths running without authenticated tenant context; copying tenantId from an entity where TENANT_ID_ is empty string but code yields null.

Related errors


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

Appendix: source

Thrown at modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchPartQueryImpl.java:175

            throw new FlowableIllegalArgumentException("subScopeId is null");
        }
        this.subScopeId = subScopeId;
        return this;
    }

    @Override
    public BatchPartQuery scopeType(String scopeType) {
        if (scopeType == null) {
            throw new FlowableIllegalArgumentException("scopeType is null");
        }
        this.scopeType = scopeType;
        return this;
    }

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

    @Override
    public BatchPartQuery tenantIdLike(String tenantIdLike) {
        if (tenantIdLike == null) {
            throw new FlowableIllegalArgumentException("tenantIdLike is null");
        }
        this.tenantIdLike = tenantIdLike;
        return this;
    }

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

View on GitHub (pinned to d6d39ce1c6)