flowable/flowable-engine · error · ActivitiIllegalArgumentException

deploymentTenantId is null

Error message

deploymentTenantId is null

What it means

DeploymentQueryImpl.deploymentTenantId() throws ActivitiIllegalArgumentException when the tenantId argument is null. Tenant filtering requires an explicit tenant identifier; null is rejected so queries never silently lose tenant isolation.

Solutions

  1. Pass a non-null tenant id string
  2. Resolve the tenant context before querying and fail fast if it is missing
  3. Only add the tenant filter when a tenant is known; otherwise use a deliberately scoped query
  4. Fix the tenant provider/header extraction returning null

Example fix

// before
query.deploymentTenantId(TenantContext.getCurrentTenantId());
// after
String tenantId = TenantContext.getCurrentTenantId();
if (tenantId == null) {
    throw new IllegalStateException("No tenant context available");
}
query.deploymentTenantId(tenantId);
Defensive patterns

Strategy: validation

Validate before calling

if (tenantId == null) { throw new IllegalStateException("Tenant context is required for deployment queries"); }
repositoryService.createDeploymentQuery().deploymentTenantId(tenantId)...

Type guard

boolean hasTenantContext(TenantContext ctx) { return ctx != null && ctx.getCurrentTenantId() != null; }

Try / catch

try {
    repositoryService.createDeploymentQuery().deploymentTenantId(tenantId).list();
} catch (ActivitiIllegalArgumentException e) {
    log.error("tenantId was null; missing tenant context?", e);
}

Prevention

When it happens

Trigger: Calling repositoryService.createDeploymentQuery().deploymentTenantId(null), commonly when the tenant id comes from a context holder, security principal, or request header that is absent (e.g. unauthenticated or non-multi-tenant call).

Common situations: Multi-tenant applications where the tenant resolver returns null outside a tenant-scoped request; jobs/schedulers running without tenant context; renamed tenant keys in configuration.

Related errors


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

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/DeploymentQueryImpl.java:102

            throw new ActivitiIllegalArgumentException("deploymentCategory is null");
        }
        this.category = deploymentCategory;
        return this;
    }

    @Override
    public DeploymentQueryImpl deploymentCategoryNotEquals(String deploymentCategoryNotEquals) {
        if (deploymentCategoryNotEquals == null) {
            throw new ActivitiIllegalArgumentException("deploymentCategoryExclude is null");
        }
        this.categoryNotEquals = deploymentCategoryNotEquals;
        return this;
    }

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

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

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

View on GitHub (pinned to d6d39ce1c6)