{"record":{"id":"b61c83df7aded574","repo":"flowable/flowable-engine","slug":"tenantid-is-null-b61c83","errorCode":null,"errorMessage":"TenantId is null","messagePattern":"TenantId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/UserQueryImpl.java","lineNumber":231,"sourceCode":"            throw new FlowableIllegalArgumentException(\"Provided groupId is null\");\n        }\n        this.groupId = groupId;\n        return this;\n    }\n\n    @Override\n    public UserQuery memberOfGroups(List<String> groupIds) {\n        if (groupIds == null) {\n            throw new FlowableIllegalArgumentException(\"Provided groupIds is null\");\n        }\n        this.groupIds = groupIds;\n        return this;\n    }\n\n    @Override\n    public UserQuery tenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"TenantId is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    // sorting //////////////////////////////////////////////////////////\n\n    @Override\n    public UserQuery orderByUserId() {\n        return orderBy(UserQueryProperty.USER_ID);\n    }\n\n    @Override\n    public UserQuery orderByUserEmail() {\n        return orderBy(UserQueryProperty.EMAIL);\n    }\n\n    @Override","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/UserQueryImpl.java#L213-L249","documentation":"UserQueryImpl.tenantId(String) throws FlowableIllegalArgumentException when the tenantId argument is null. Flowable multi-tenancy queries require an explicit tenant identifier; a null tenant would silently change result scope, so it is rejected. Pass a valid tenant id or omit the criterion.","triggerScenarios":"Calling identityService.createUserQuery().tenantId(null).","commonSituations":"The tenant id comes from a tenant-context holder that is unset outside a tenant-scoped request (background jobs, system-level startup code), then flows into the query.","solutions":["Pass a valid tenant id string.","Guard: only apply tenantId() when the resolved tenant is non-null.","Fix the tenant-context provider so it returns a concrete tenant for this execution path."],"exampleFix":"// before\nUserQuery q = identityService.createUserQuery().tenantId(TenantContext.getTenantId());\n// after\nUserQuery q = identityService.createUserQuery();\nString tenantId = TenantContext.getTenantId();\nif (tenantId != null) {\n    q = q.tenantId(tenantId);\n}","handlingStrategy":"validation","validationCode":"if (tenantId != null && !tenantId.isBlank()) { query = query.tenantId(tenantId); }","typeGuard":"boolean hasTenant(String t) { return t != null && !t.isBlank(); }","tryCatchPattern":"try { query.tenantId(tenantId); } catch (FlowableIllegalArgumentException e) { log.warn(\"Null tenantId ignored\", e); }","preventionTips":["Ensure the tenant context is populated for all execution paths including background jobs","Fail fast with a clear message when tenant resolution returns null in multi-tenant mode","Centralize tenant extraction in one utility that guarantees non-null or explicit 'no tenant' semantics"],"tags":["flowable","idm","null-argument","tenant"],"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"}