{"record":{"id":"3de82eb5a3b14a1a","repo":"flowable/flowable-engine","slug":"process-definition-tenantid-is-null-3de82e","errorCode":null,"errorMessage":"process definition tenantId is null","messagePattern":"process definition tenantId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessDefinitionQueryImpl.java","lineNumber":265,"sourceCode":"    @Override\n    public ProcessDefinitionQuery suspended() {\n        this.suspensionState = SuspensionState.SUSPENDED;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery processDefinitionTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new ActivitiIllegalArgumentException(\"processDefinition tenantId is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery processDefinitionTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new ActivitiIllegalArgumentException(\"process definition tenantId is null\");\n        }\n        this.tenantIdLike = tenantIdLike;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery processDefinitionWithoutTenantId() {\n        this.withoutTenantId = true;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery messageEventSubscription(String messageName) {\n        return eventSubscription(\"message\", messageName);\n    }\n\n    @Override\n    public ProcessDefinitionQuery messageEventSubscriptionName(String messageName) {","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessDefinitionQueryImpl.java#L247-L283","documentation":"Flowable/Activiti query builders validate arguments eagerly. processDefinitionTenantIdLike() throws ActivitiIllegalArgumentException when the tenantIdLike parameter is null, because a null 'like' filter cannot be translated to a meaningful SQL predicate.","triggerScenarios":"Calling ProcessDefinitionQuery.processDefinitionTenantIdLike(null), typically when the tenant id comes from an uninitialized variable, a config property that is missing, or a TenantContext that returned null.","commonSituations":"Multi-tenant apps where the tenant id is resolved from a header/token at runtime and is absent for anonymous or misconfigured requests; unit tests constructing queries without setting tenant context.","solutions":["Pass a non-null tenant id string to processDefinitionTenantIdLike()","If the intent is 'any tenant', omit the tenant filter entirely or use the tenantIdLike value '*' (all tenants) instead of null","Guard the caller: only add the tenant filter when a tenant id is actually available","Catch ActivitiIllegalArgumentException around query construction to surface a clear 400-style message"],"exampleFix":"// before\nquery.processDefinitionTenantIdLike(tenantCtx.getTenantId()); // tenantId may be null\n// after\nif (tenantCtx.getTenantId() != null) {\n    query.processDefinitionTenantIdLike(tenantCtx.getTenantId());\n}","handlingStrategy":"validation","validationCode":"if (tenantIdLike == null) {\n    throw new IllegalArgumentException(\"tenantIdLike must not be null\");\n}\nquery.processDefinitionTenantIdLike(tenantIdLike);","typeGuard":"boolean hasTenantId(String t) { return t != null && !t.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.processDefinitionTenantIdLike(tenantId);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"tenantId\")) {\n        throw new InvalidRequestException(\"tenantId is required\");\n    }\n    throw e;\n}","preventionTips":["Resolve tenant id from a single validated source (header/token) before querying","Use a helper that applies tenant filters only when a tenant is present","Add unit tests for null-tenant query construction","Prefer '*' or no filter over null for 'all tenants' semantics"],"tags":["java","activiti","query","null-argument","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-14T05:17:10.506Z"}