{"record":{"id":"e8cce28aa88f69d1","repo":"flowable/flowable-engine","slug":"caseinstance-tenant-id-is-null","errorCode":null,"errorMessage":"caseInstance tenant id is null","messagePattern":"caseInstance tenant id is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java","lineNumber":832,"sourceCode":"    }\n\n    @Override\n    public HistoricCaseInstanceQuery caseInstanceReferenceType(String referenceType) {\n        if (referenceType == null) {\n            throw new FlowableIllegalArgumentException(\"referenceType is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.referenceType = referenceType;\n        } else {\n            this.referenceType = referenceType;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQueryImpl caseInstanceTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstance 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 HistoricCaseInstanceQueryImpl caseInstanceTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstance tenant id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.tenantIdLike = tenantIdLike;\n        } else {\n            this.tenantIdLike = tenantIdLike;","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L814-L850","documentation":"HistoricCaseInstanceQueryImpl.caseInstanceTenantId(String) throws FlowableIllegalArgumentException with message 'caseInstance tenant id is null' when tenantId is null. Tenant id filters restrict results to one tenant; null is not accepted — to ignore tenancy, simply do not call this method.","triggerScenarios":"Calling caseInstanceTenantId(null) directly or inside an or() block, typically when the tenant was resolved from a nullable context (user profile, request header, tenant context holder).","commonSituations":"Multi-tenant apps where the tenant resolver returns null for unauthenticated/system calls; copying tenant handling from caseInstanceTenantIdLike variants; wiring the tenant id from a config key that is missing.","solutions":["Pass a non-null tenant id string matching the tenant of the case instances.","Omit the tenant filter entirely when querying across tenants (no 'null tenant' concept in the query API).","If an empty tenant is valid in your model, use caseInstanceTenantIdLike(\"\") semantics carefully or filter client-side — never pass null."],"exampleFix":"// before\nquery.caseInstanceTenantId(tenantContext.getTenantId()); // may be null\n// after\nString tenantId = tenantContext.getTenantId();\nif (tenantId != null) {\n    query.caseInstanceTenantId(tenantId);\n}","handlingStrategy":"validation","validationCode":"String tenantId = tenantContext.getTenantId();\nif (tenantId != null) {\n    query.caseInstanceTenantId(tenantId);\n} // else: query without tenant restriction","typeGuard":"boolean hasTenant(String t) { return t != null && !t.isEmpty(); }","tryCatchPattern":"try {\n    query.caseInstanceTenantId(tenantId);\n} catch (FlowableIllegalArgumentException e) {\n    throw new IllegalStateException(\"Tenant context not initialized\", e);\n}","preventionTips":["Do not call tenant filters when the tenant is unknown — null is never accepted.","Initialize the tenant context before executing tenant-scoped queries.","Cover multi-tenant query paths with unit tests using a null-tenant scenario."],"tags":["null-argument","query","cmmn","tenant","validation"],"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"}