{"record":{"id":"b5bca09ee594c974","repo":"flowable/flowable-engine","slug":"casedefinition-tenantid-is-null","errorCode":null,"errorMessage":"caseDefinition tenantId is null","messagePattern":"caseDefinition tenantId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CaseDefinitionQueryImpl.java","lineNumber":264,"sourceCode":"\n    protected void checkVersion(Integer version) {\n        if (version == null) {\n            throw new FlowableIllegalArgumentException(\"version is null\");\n        } else if (version <= 0) {\n            throw new FlowableIllegalArgumentException(\"version must be positive\");\n        }\n    }\n\n    @Override\n    public CaseDefinitionQueryImpl latestVersion() {\n        this.latest = true;\n        return this;\n    }\n\n    @Override\n    public CaseDefinitionQuery caseDefinitionTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"caseDefinition tenantId is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    @Override\n    public CaseDefinitionQuery caseDefinitionTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"case definition tenantId is null\");\n        }\n        this.tenantIdLike = tenantIdLike;\n        return this;\n    }\n\n    @Override\n    public CaseDefinitionQuery caseDefinitionWithoutTenantId() {\n        this.withoutTenantId = true;\n        return this;","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CaseDefinitionQueryImpl.java#L246-L282","documentation":"caseDefinitionTenantId in CaseDefinitionQueryImpl throws FlowableIllegalArgumentException with \"caseDefinition tenantId is null\" when passed a null tenantId. Multi-tenancy filters must be explicit strings; to query across tenants simply omit the filter rather than passing null.","triggerScenarios":"Calling caseDefinitionTenantId(null) — typically when the tenant id is taken from an unauthenticated request context, a missing header (e.g. X-Tenant-Id), or a Map lookup that returned null.","commonSituations":"TenantContext not populated because tenant resolution middleware did not run; single-tenant deployments where tenant id was never configured; passing the result of TenantProvider.getTenant() that returns null for the default tenant.","solutions":["Null-check the tenantId and only call caseDefinitionTenantId when non-null.","Ensure tenant resolution (header/context/config) is in place and returns a real tenant id before building the query.","If all tenants should be searched, drop the tenant filter call entirely."],"exampleFix":"// before\nquery.caseDefinitionTenantId(tenantContext.getCurrentTenantId());\n\n// after\nString tenantId = tenantContext.getCurrentTenantId();\nif (tenantId != null) {\n    query.caseDefinitionTenantId(tenantId);\n}","handlingStrategy":"validation","validationCode":"String tenantId = tenantContext.getCurrentTenantId();\nif (tenantId != null && !tenantId.isEmpty()) {\n    query.caseDefinitionTenantId(tenantId);\n}","typeGuard":"boolean hasTenant(String t) { return t != null && !t.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.caseDefinitionTenantId(tenantId);\n} catch (FlowableIllegalArgumentException e) {\n    if (!e.getMessage().contains(\"tenantId is null\")) throw e;\n    query = repositoryService.createCaseDefinitionQuery(); // unfiltered fallback\n}","preventionTips":["Resolve the tenant id before entering repository code","Assert tenant context is populated in integration tests","For cross-tenant queries, omit the filter explicitly rather than passing null"],"tags":["null-argument","multi-tenancy","query-builder","cmmn"],"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"}