{"record":{"id":"9d51c8ce5692025c","repo":"flowable/flowable-engine","slug":"task-tenant-id-is-null-9d51c8","errorCode":null,"errorMessage":"task tenant id is null","messagePattern":"task tenant id is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java","lineNumber":692,"sourceCode":"            this.candidateGroups = candidateGroups;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQuery ignoreAssigneeValue() {\n        if (orActive) {\n            currentOrQueryObject.ignoreAssigneeValue = true;\n        } else {\n            this.ignoreAssigneeValue = true;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQuery taskTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"task tenant id is null\");\n        }\n        if (orActive) {\n            currentOrQueryObject.tenantId = tenantId;\n        } else {\n            this.tenantId = tenantId;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQuery taskTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"task tenant id is null\");\n        }\n        if (orActive) {\n            currentOrQueryObject.tenantIdLike = tenantIdLike;\n        } else {\n            this.tenantIdLike = tenantIdLike;","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java#L674-L710","documentation":"Flowable's TaskQueryImpl.taskTenantId() validates its argument before storing the query filter. Passing a null tenant id would produce an ambiguous SQL predicate, so the library fails fast with FlowableIllegalArgumentException. The caller must supply a non-null tenant id string (or use taskWithoutTenantId for null-tenant tasks).","triggerScenarios":"Calling taskService.createTaskQuery().taskTenantId(null), directly or via a variable holding the tenant id that is null at runtime.","commonSituations":"Tenant id resolved from user session, config, or request header is unset/null; multi-tenant setups where a fallback default tenant was never configured.","solutions":["Pass an actual tenant id string, e.g. .taskTenantId(\"acme\")","If you mean tasks with no tenant, call taskWithoutTenantId() instead","Null-check the variable before building the query and skip the filter or fall back to a default tenant"],"exampleFix":"// before\nString tenant = getTenantFromSession(); // may be null\nList<Task> tasks = taskService.createTaskQuery().taskTenantId(tenant).list();\n// after\nString tenant = getTenantFromSession();\nTaskQuery query = taskService.createTaskQuery();\nif (tenant != null) { query = query.taskTenantId(tenant); }\nList<Task> tasks = query.list();","handlingStrategy":"validation","validationCode":"if (tenantId == null) {\n    throw new IllegalArgumentException(\"tenantId must be set before calling taskTenantId\");\n}\nquery.taskTenantId(tenantId);","typeGuard":"boolean hasTenant(String t) { return t != null && !t.trim().isEmpty(); }","tryCatchPattern":"try {\n    tasks = taskService.createTaskQuery().taskTenantId(tenantId).list();\n} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid query argument: {}\", e.getMessage());\n    tasks = Collections.emptyList();\n}","preventionTips":["Resolve tenant id from a guaranteed source (authenticated principal) with a configured default","Null-check tenant ids at the entry point of your service layer","Use taskWithoutTenantId() for null-tenant tasks instead of passing null","Write a unit test covering queries with each dynamic filter parameter"],"tags":["flowable","task-query","null-argument","tenant-id"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}