{"record":{"id":"35615a21a2be0e8b","repo":"flowable/flowable-engine","slug":"provided-case-instance-id-is-null-35615a","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/SuspendedJobQueryImpl.java","lineNumber":327,"sourceCode":"    }\n    \n    @Override\n    public SuspendedJobQueryImpl 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 SuspendedJobQueryImpl 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 SuspendedJobQueryImpl 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 SuspendedJobQueryImpl caseDefinitionKey(String caseDefinitionKey) {","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/SuspendedJobQueryImpl.java#L309-L345","documentation":"This FlowableIllegalArgumentException is thrown by SuspendedJobQueryImpl.caseInstanceId() when the caller passes a null case instance id. The method delegates to scopeId() with the id and sets the scope type to CMMN; the id null-check fires first. This fail-fast validation prevents building a query with an invalid CMMN scope filter.","triggerScenarios":"Calling suspendedJobQuery().caseInstanceId(null), typically when the case instance was not found, an optional path/parameter was absent, or a lookup returned null.","commonSituations":"Chaining from a CaseInstance variable that is null (instance not started or already completed); REST handlers passing missing query params; batch jobs iterating over possibly-absent case references.","solutions":["Check CaseInstance/lookup results for null before querying by id","Only call caseInstanceId() when a valid id is available; otherwise use an unfiltered or different query","Fix upstream resolution logic to handle 'not found' explicitly","Validate request parameters before mapping to the query"],"exampleFix":"// before\nCaseInstance ci = runtimeService.createCaseInstanceQuery().caseInstanceBusinessKey(bk).singleResult();\nquery.caseInstanceId(ci.getId()); // NPE risk / null id\n// after\nCaseInstance ci = runtimeService.createCaseInstanceQuery().caseInstanceBusinessKey(bk).singleResult();\nif (ci != null) {\n    query.caseInstanceId(ci.getId());\n}","handlingStrategy":"validation","validationCode":"if (caseInstanceId != null) {\n    query.caseInstanceId(caseInstanceId);\n}","typeGuard":"boolean hasCaseInstanceId = caseInstanceId != null && !caseInstanceId.isBlank();","tryCatchPattern":"try {\n    query.caseInstanceId(caseInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"case instance id is null\")) {\n        // handle absence of case instance explicitly (log, skip, or alternate query)\n    } else {\n        throw e;\n    }\n}","preventionTips":["Null-check CaseInstance lookup results before reading getId()","Treat 'case not found' as a distinct branch, not a null pass-through","Validate REST/path parameters before building queries","Use Optional for optional case references and map to a query only if present"],"tags":["java","flowable","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"}