{"record":{"id":"ccbcdc94bf2915cd","repo":"flowable/flowable-engine","slug":"provided-case-instance-id-is-null-ccbcdc","errorCode":null,"errorMessage":"Provided case instance id is null","messagePattern":"Provided case instance 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":317,"sourceCode":"    }\n\n    @Override\n    public JobQueryImpl scopeDefinitionId(String scopeDefinitionId) {\n        if (scopeDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope definitionid is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.scopeDefinitionId = scopeDefinitionId;\n        } else {\n            this.scopeDefinitionId = scopeDefinitionId;\n        }\n        return this;\n    }\n\n    @Override\n    public JobQueryImpl caseInstanceId(String caseInstanceId) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"Provided case instance id is null\");\n        }\n        scopeId(caseInstanceId);\n        scopeType(ScopeTypes.CMMN);\n        return this;\n    }\n\n    @Override\n    public JobQueryImpl caseDefinitionId(String caseDefinitionId) {\n        if (caseDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"Provided case definition id is null\");\n        }\n        scopeDefinitionId(caseDefinitionId);\n        scopeType(ScopeTypes.CMMN);\n        return this;\n    }\n\n    @Override\n    public JobQueryImpl caseDefinitionKey(String caseDefinitionKey) {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/JobQueryImpl.java#L299-L335","documentation":"JobQueryImpl.caseInstanceId(String) requires a non-null case instance id and throws FlowableIllegalArgumentException otherwise. Internally it maps the filter to scopeId(caseInstanceId) plus scopeType(ScopeTypes.CMMN); the null check happens before that delegation so the failure is immediate. It is a fail-fast guard against building a CMMN job query without an instance to scope to.","triggerScenarios":"Calling jobQuery.caseInstanceId(null), e.g. when the case instance id comes from a nullable variable, an entity that was not found, or an unset execution/plan-item context.","commonSituations":"A CaseInstance lookup returned null (wrong id or instance already ended/purged); job query built generically for both process and case jobs with only the process id set; deserialized task/plan-item data missing the caseInstanceId field.","solutions":["Check that the case instance exists and the id variable is populated before querying","For BPMN jobs use processInstanceId/scopeId with BPMN scope instead of caseInstanceId","Skip the caseInstanceId filter when null and use a broader query, then filter in code","Null-guard the variable at the call site"],"exampleFix":"// before\nList<Job> jobs = jobService.createJobQuery().caseInstanceId(caseInstanceId).list();\n// after\nif (caseInstanceId != null) {\n    List<Job> jobs = jobService.createJobQuery().caseInstanceId(caseInstanceId).list();\n} else {\n    List<Job> jobs = Collections.emptyList();\n}","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null) { throw new IllegalArgumentException(\"caseInstanceId must not be null\"); }\njobQuery.caseInstanceId(caseInstanceId);","typeGuard":"boolean hasCaseInstanceId(String id) { return id != null; }","tryCatchPattern":"try {\n    jobQuery.caseInstanceId(caseInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    logger.warn(\"caseInstanceId was null\", e);\n}","preventionTips":["Confirm the case instance exists before scoping jobs to it","Null-check ids from plan items/tasks before building queries","Keep process and case job queries in separate code paths to avoid unset ids"],"tags":["flowable","java","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-14T05:17:10.506Z"}