{"record":{"id":"bf5b7219406814bd","repo":"flowable/flowable-engine","slug":"task-tenant-id-is-null","errorCode":null,"errorMessage":"task tenant id is null","messagePattern":"task tenant id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":1984,"sourceCode":"            this.involvedGroups = involvedGroups;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery ignoreAssigneeValue() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.ignoreAssigneeValue = true;\n        } else {\n            this.ignoreAssigneeValue = true;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"task tenant id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.tenantId = tenantId;\n        } else {\n            this.tenantId = tenantId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"task tenant id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.tenantIdLike = tenantIdLike;\n        } else {\n            this.tenantIdLike = tenantIdLike;","sourceCodeStart":1966,"sourceCodeEnd":2002,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java#L1966-L2002","documentation":"taskTenantId(String) throws FlowableIllegalArgumentException when the tenantId argument is null. Flowable requires an explicit non-null tenant id string for tenant-scoped queries; use taskWithoutTenantId() or omit the filter to match tasks without a tenant.","triggerScenarios":"Calling taskTenantId(null) — usually a tenant resolved from a multi-tenant context that is null (e.g. no tenant in the session/HTTP header), or a task.getTenantId() on a task created before tenant support.","commonSituations":"Multi-tenancy setups where the tenant resolver returns null for global/admin users or when the tenant header is missing; forwarding a task's tenantId when tasks were deployed without one (empty string vs null confusion).","solutions":["Pass a non-null tenant id; resolve/validate the tenant from the request context first.","To query tasks with no tenant, use taskWithoutTenantId() instead of passing null.","If tenant filtering is optional, call taskTenantId() only when a tenant id is present.","Note Flowable stores missing tenants as empty string (\"\"); pass \"\" if you intentionally filter that value, or prefer taskWithoutTenantId()."],"exampleFix":"// before\nquery.taskTenantId(tenantContext.getTenantId()); // throws when null\n\n// after\nString tenantId = tenantContext.getTenantId();\nif (tenantId != null) {\n    query.taskTenantId(tenantId);\n} else {\n    query.taskWithoutTenantId();\n}","handlingStrategy":"validation","validationCode":"if (tenantId != null && !tenantId.isEmpty()) {\n    historicTaskInstanceQuery.taskTenantId(tenantId);\n} else {\n    historicTaskInstanceQuery.taskWithoutTenantId(); // or omit the filter\n}","typeGuard":"boolean isValidTenant(String tenantId) {\n    return tenantId != null && !tenantId.isEmpty();\n}","tryCatchPattern":"try {\n    query.taskTenantId(tenantId);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid tenantId filter: {}\", e.getMessage());\n    query.taskWithoutTenantId();\n}","preventionTips":["Resolve the tenant once at request entry and fail fast if missing (or default to a known tenant).","Use taskWithoutTenantId() for no-tenant queries, never taskTenantId(null).","Remember Flowable stores absent tenants as empty string; map '' handling explicitly."],"tags":["flowable","query-validation","null-argument","multi-tenancy"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}