{"record":{"id":"70fe09bafaa28d83","repo":"flowable/flowable-engine","slug":"model-tenant-id-is-null-70fe09","errorCode":null,"errorMessage":"Model tenant id is null","messagePattern":"Model tenant id is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ModelQueryImpl.java","lineNumber":165,"sourceCode":"            throw new ActivitiIllegalArgumentException(\"Invalid usage: cannot use deployed() and notDeployed() in the same query\");\n        }\n        this.notDeployed = true;\n        return this;\n    }\n\n    @Override\n    public ModelQuery deployed() {\n        if (notDeployed) {\n            throw new ActivitiIllegalArgumentException(\"Invalid usage: cannot use deployed() and notDeployed() in the same query\");\n        }\n        this.deployed = true;\n        return this;\n    }\n\n    @Override\n    public ModelQuery modelTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new ActivitiIllegalArgumentException(\"Model tenant id is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    @Override\n    public ModelQuery modelTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new ActivitiIllegalArgumentException(\"Model tenant id is null\");\n        }\n        this.tenantIdLike = tenantIdLike;\n        return this;\n    }\n\n    @Override\n    public ModelQuery modelWithoutTenantId() {\n        this.withoutTenantId = true;\n        return this;","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ModelQueryImpl.java#L147-L183","documentation":"ModelQueryImpl.modelTenantId(String) filters models by an exact tenant id for multi-tenant deployments. Flowable throws ActivitiIllegalArgumentException when the tenantId is null, because a null tenant cannot form a valid equality filter.","triggerScenarios":"Calling modelQuery.modelTenantId(null) — usually when the tenant id comes from an unset context (e.g. TenantContext or request header absent).","commonSituations":"Multi-tenant apps where the authenticated user has no tenant assigned; configuration or environment variable for tenant id missing; single-tenant setups that still call the tenant filter with null.","solutions":["Pass a valid, non-null tenant id that exists in the deployment.","Null-check the tenant id (from context/config) before applying the filter; skip the filter if tenant filtering is not needed.","Set a default tenant id (e.g. \"\" or a configured default) when tenant context is absent.","Catch ActivitiIllegalArgumentException around query building to return a clear error to the client."],"exampleFix":"// before\nquery.modelTenantId(tenantContext.getTenantId()); // may be null\n// after\nString tenantId = tenantContext.getTenantId();\nif (tenantId != null) {\n    query.modelTenantId(tenantId);\n}","handlingStrategy":"validation","validationCode":"String tenantId = tenantContext.getTenantId();\nif (tenantId != null) {\n    query.modelTenantId(tenantId);\n}","typeGuard":"boolean hasTenant(String t) { return t != null && !t.isEmpty(); }","tryCatchPattern":"try {\n    query.modelTenantId(tenantId);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    throw new BadRequestException(\"tenant id is required for this query\", e);\n}","preventionTips":["Resolve tenant context before query building and fail fast if absent.","Configure a default tenant for single-tenant deployments.","Only apply tenant filters when multi-tenancy is enabled."],"tags":["activiti","flowable","multi-tenancy","null-argument"],"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"}