flowable/flowable-engine · error · FlowableIllegalArgumentException

activity tenant id is null

Error message

activity tenant id is null

What it means

ActivityInstanceQueryImpl.activityTenantId requires a non-null tenant id string. Passing null throws FlowableIllegalArgumentException because a null tenant filter is ambiguous with 'no tenant filter' — the API requires omitting the call entirely to query across tenants.

Solutions

  1. Only call activityTenantId when the tenant id is non-null
  2. Default the tenant to a concrete value (e.g. the application's default tenant) before querying
  3. Catch FlowableIllegalArgumentException and return a clear 'tenant required' validation message

Example fix

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

Strategy: validation

Validate before calling

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

Type guard

boolean hasTenant = tenantId != null && !tenantId.trim().isEmpty();

Try / catch

try { query.activityTenantId(tenantId); } catch (FlowableIllegalArgumentException e) { throw new BadRequestException("tenantId is required"); }

Prevention

When it happens

Trigger: Calling .activityTenantId(null) when the tenant value comes from a nullable request parameter, configuration, or security context.

Common situations: Multi-tenant apps where the tenant header/context is missing; passing a user profile's tenantId that was never populated; builders that unconditionally chain tenant filters.

Related errors


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

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/ActivityInstanceQueryImpl.java:163

        return this;
    }

    @Override
    public ActivityInstanceQuery deleteReason(String deleteReason) {
        this.deleteReason = deleteReason;
        return this;
    }

    @Override
    public ActivityInstanceQuery deleteReasonLike(String deleteReasonLike) {
        this.deleteReasonLike = deleteReasonLike;
        return this;
    }

    @Override
    public ActivityInstanceQueryImpl activityTenantId(String tenantId) {
        if (tenantId == null) {
            throw new FlowableIllegalArgumentException("activity tenant id is null");
        }
        this.tenantId = tenantId;
        return this;
    }

    public String getTenantId() {
        return tenantId;
    }

    @Override
    public ActivityInstanceQueryImpl activityTenantIdLike(String tenantIdLike) {
        if (tenantIdLike == null) {
            throw new FlowableIllegalArgumentException("activity tenant id is null");
        }
        this.tenantIdLike = tenantIdLike;
        return this;
    }

View on GitHub (pinned to d6d39ce1c6)