{"record":{"id":"f2b008c6b2ae670c","repo":"flowable/flowable-engine","slug":"provided-tenant-id-is-null-f2b008","errorCode":null,"errorMessage":"Provided tenant id is null","messagePattern":"Provided tenant id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/HistoryJobQueryImpl.java","lineNumber":151,"sourceCode":"    }\n\n    @Override\n    public HistoryJobQuery scopeType(String scopeType) {\n        if (scopeType == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope type is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.scopeType = scopeType;\n        } else {\n            this.scopeType = scopeType;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoryJobQuery jobTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"Provided 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 HistoryJobQuery jobTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"Provided tenant id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.tenantIdLike = tenantIdLike;\n        } else {\n            this.tenantIdLike = tenantIdLike;","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/HistoryJobQueryImpl.java#L133-L169","documentation":"HistoryJobQuery.jobTenantId(String) throws FlowableIllegalArgumentException when tenantId is null. Tenant filtering is a common multi-tenancy requirement, and Flowable validates that the tenant id passed to this method is non-null rather than issuing a query with a null tenant criterion.","triggerScenarios":"Calling historyJobQuery.jobTenantId(null), directly or in an or() block, e.g. when the tenant id comes from an unauthenticated context, a missing header/variable, or an entity whose tenant was never set.","commonSituations":"Multi-tenant applications where the tenant resolver returned null (missing tenant header, anonymous request); passing a nullable tenant field from a process/entity; generic query builders that always call jobTenantId().","solutions":["Only call jobTenantId() when a tenant id is known; otherwise omit it to query across tenants","Use jobTenantIdLike() if partial matching is intended (also requires non-null)","Guard: if (tenantId != null) query.jobTenantId(tenantId)","Fix tenant resolution (auth/context setup) so the id is always populated for tenant-scoped requests"],"exampleFix":"// before\nquery.jobTenantId(tenantId); // may be null\n// after\nif (tenantId != null) {\n    query.jobTenantId(tenantId);\n}","handlingStrategy":"validation","validationCode":"if (tenantId == null) { throw new IllegalArgumentException(\"tenantId is required for tenant-scoped queries\"); }\nhistoryJobQuery.jobTenantId(tenantId);","typeGuard":"boolean hasTenantId(String t) { return t != null && !t.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.jobTenantId(tenantId);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"tenant filter skipped: {}\", e.getMessage());\n}","preventionTips":["Resolve the tenant id in a filter/interceptor and reject tenant-scoped requests without one","Apply jobTenantId() conditionally; an unset tenant usually means 'query all tenants'","Centralize tenant extraction so null tenants surface at the boundary"],"tags":["java","flowable","null-check","multi-tenancy","query-api"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T16:30:33.424Z"}