{"record":{"id":"6e9f6b745d004d5a","repo":"flowable/flowable-engine","slug":"activity-tenant-id-is-null-6e9f6b","errorCode":null,"errorMessage":"activity tenant id is null","messagePattern":"activity tenant id is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricActivityInstanceQueryImpl.java","lineNumber":131,"sourceCode":"\n    @Override\n    public HistoricActivityInstanceQueryImpl finished() {\n        this.finished = true;\n        this.unfinished = false;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl unfinished() {\n        this.unfinished = true;\n        this.finished = false;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl activityTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new ActivitiIllegalArgumentException(\"activity tenant id is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl activityTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new ActivitiIllegalArgumentException(\"activity tenant id is null\");\n        }\n        this.tenantIdLike = tenantIdLike;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl activityWithoutTenantId() {\n        this.withoutTenantId = true;\n        return this;","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricActivityInstanceQueryImpl.java#L113-L149","documentation":"HistoricActivityInstanceQueryImpl.activityTenantId(tenantId) validates that the tenant id used as an exact-match filter is not null. Tenant filtering by equality to null is not supported, so the library fails fast with ActivitiIllegalArgumentException. Use activityTenantIdWithoutTenant() if you specifically want activities with no tenant.","triggerScenarios":"Calling historicActivityInstanceQuery.activityTenantId(null), typically when the tenant id comes from an unset context variable, a missing authenticated tenant, or an optional config value.","commonSituations":"Multi-tenant deployments where the tenant context is not populated (e.g. calling from a job or async executor without tenant context); users omitting the tenant in an API request; migrations from single-tenant setups.","solutions":["Pass a concrete tenant id string to activityTenantId().","If the intent is 'no tenant', call activityTenantIdWithoutTenant() instead of passing null.","Guard the call site: only invoke the query when TenantContext.getTenantId() is non-null.","Propagate tenant id explicitly into async/job code paths where the context is lost."],"exampleFix":"// before\nString tenant = TenantContext.getTenantId(); // may be null\nquery.activityTenantId(tenant);\n// after\nString tenant = TenantContext.getTenantId();\nif (tenant != null) {\n    query.activityTenantId(tenant);\n} else {\n    query.activityTenantIdWithoutTenant();\n}","handlingStrategy":"validation","validationCode":"if (tenantId == null && !allowTenantless) throw new IllegalArgumentException(\"tenantId required for activityTenantId()\");","typeGuard":"boolean hasTenant(String t) { return t != null && !t.isEmpty(); }","tryCatchPattern":"try {\n    query.activityTenantId(tenantId);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"activity tenant id is null\")) {\n        query.activityTenantIdWithoutTenant(); // fallback for tenantless data\n    }\n}","preventionTips":["Use activityTenantIdWithoutTenant() for the no-tenant case.","Propagate tenant context into async/job code paths.","Default missing tenant config explicitly at startup.","Reject missing tenant at your API boundary before reaching the query."],"tags":["java","activiti","query","tenant","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-18T11:17:12.947Z"}