{"record":{"id":"589d4ffaf07fd7d9","repo":"flowable/flowable-engine","slug":"provided-scope-id-is-null-589d4f","errorCode":null,"errorMessage":"Provided scope id is null","messagePattern":"Provided scope id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/JobQueryImpl.java","lineNumber":242,"sourceCode":"    }\n\n    @Override\n    public JobQueryImpl elementName(String elementName) {\n        if (elementName == null) {\n            throw new FlowableIllegalArgumentException(\"Provided element name is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.elementName = elementName;\n        } else {\n            this.elementName = elementName;\n        }\n        return this;\n    }\n\n    @Override\n    public JobQueryImpl scopeId(String scopeId) {\n        if (scopeId == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.scopeId = scopeId;\n        } else {\n            this.scopeId = scopeId;\n        }\n        return this;\n    }\n\n    @Override\n    public JobQuery scopeIds(Collection<String> scopeIds) {\n        if (scopeIds == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope ids are null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.scopeIds = scopeIds;\n        } else {\n            this.scopeIds = scopeIds;","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/JobQueryImpl.java#L224-L260","documentation":"JobQueryImpl.scopeId(String) throws FlowableIllegalArgumentException when the scope id is null. Scope ids identify scopes such as cases or processes (also used internally by caseInstanceId(), which delegates here), and null is rejected at query construction. Flowable validates every filter argument eagerly so invalid queries fail immediately.","triggerScenarios":"Calling scopeId(id) with a null string, or calling caseInstanceId(caseId) with null which routes into scopeId(); also triggered when a scope lookup (case/process instance) returned null.","commonSituations":"CMMN case handling where the case instance id was never captured; querying jobs after an instance already terminated and its lookup returns null; nullable scope fields mapped from request DTOs.","solutions":["Obtain the real scope id from the CaseInstance/Execution (e.g. caseInstance.getId()) before querying","Guard the call with a null check and omit the filter when absent","If using caseInstanceId(), validate the case id is non-null there; the same error is thrown from scopeId()"],"exampleFix":"// before\nquery.scopeId(scopeId);\n// after\nif (scopeId != null) {\n    query.scopeId(scopeId);\n}","handlingStrategy":"validation","validationCode":"if (scopeId == null) throw new IllegalArgumentException(\"scopeId must not be null; omit the filter instead\");","typeGuard":"boolean hasScopeId = scopeId != null && !scopeId.isEmpty();","tryCatchPattern":"try {\n    query.scopeId(scopeId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"scope id is null\")) {\n        // skip filter or rethrow with context\n    } else {\n        throw e;\n    }\n}","preventionTips":["Capture CaseInstance.getId() / Execution ids when instances start; don't re-look-up later when they may be gone","When calling caseInstanceId(), validate the case id is non-null — it delegates to scopeId()","Null-check optional scope fields in request DTOs","Use ScopeTypes constants consistently when building scope queries"],"tags":["flowable","java","query","null-check","cmmn"],"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"}