{"record":{"id":"b6ae9d013d68ca9f","repo":"flowable/flowable-engine","slug":"activity-tenant-id-is-null","errorCode":null,"errorMessage":"activity tenant id is null","messagePattern":"activity tenant id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ActivityInstanceQueryImpl.java","lineNumber":163,"sourceCode":"        return this;\n    }\n\n    @Override\n    public ActivityInstanceQuery deleteReason(String deleteReason) {\n        this.deleteReason = deleteReason;\n        return this;\n    }\n\n    @Override\n    public ActivityInstanceQuery deleteReasonLike(String deleteReasonLike) {\n        this.deleteReasonLike = deleteReasonLike;\n        return this;\n    }\n\n    @Override\n    public ActivityInstanceQueryImpl activityTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"activity tenant id is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    public String getTenantId() {\n        return tenantId;\n    }\n\n    @Override\n    public ActivityInstanceQueryImpl activityTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"activity tenant id is null\");\n        }\n        this.tenantIdLike = tenantIdLike;\n        return this;\n    }\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ActivityInstanceQueryImpl.java#L145-L181","documentation":"ActivityInstanceQueryImpl.activityTenantId requires a non-null tenant id string. Passing null throws FlowableIllegalArgumentException because a null tenant filter is ambiguous with 'no tenant filter' — the API requires omitting the call entirely to query across tenants.","triggerScenarios":"Calling .activityTenantId(null) when the tenant value comes from a nullable request parameter, configuration, or security context.","commonSituations":"Multi-tenant apps where the tenant header/context is missing; passing a user profile's tenantId that was never populated; builders that unconditionally chain tenant filters.","solutions":["Only call activityTenantId when the tenant id is non-null","Default the tenant to a concrete value (e.g. the application's default tenant) before querying","Catch FlowableIllegalArgumentException and return a clear 'tenant required' validation message"],"exampleFix":"// before\nquery.activityTenantId(tenantId);\n// after\nif (tenantId != null) {\n    query.activityTenantId(tenantId);\n}","handlingStrategy":"validation","validationCode":"if (tenantId != null) { query.activityTenantId(tenantId); }","typeGuard":"boolean hasTenant = tenantId != null && !tenantId.trim().isEmpty();","tryCatchPattern":"try { query.activityTenantId(tenantId); } catch (FlowableIllegalArgumentException e) { throw new BadRequestException(\"tenantId is required\"); }","preventionTips":["Resolve tenant from the request context and validate before querying","Omit tenant filters rather than passing null for cross-tenant queries","Provide sensible default tenant values in multi-tenant configurations","Centralize tenant handling in one query-builder helper"],"tags":["flowable","query","tenant","null-check"],"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"}