{"record":{"id":"e1b75df9862875e2","repo":"flowable/flowable-engine","slug":"case-instance-id-is-null-e1b75d","errorCode":null,"errorMessage":"Case instance id is null","messagePattern":"Case instance id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java","lineNumber":314,"sourceCode":"    }\n\n    @Override\n    public HistoricCaseInstanceQueryImpl caseDefinitionVersion(Integer caseDefinitionVersion) {\n        if (caseDefinitionVersion == null) {\n            throw new FlowableIllegalArgumentException(\"Case definition version is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.caseDefinitionVersion = caseDefinitionVersion;\n        } else {\n            this.caseDefinitionVersion = caseDefinitionVersion;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQueryImpl caseInstanceId(String caseInstanceId) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"Case instance id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.caseInstanceId = caseInstanceId;\n        } else {\n            this.caseInstanceId = caseInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQueryImpl caseInstanceIds(Set<String> caseInstanceIds) {\n        if (caseInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"Case instance ids is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.caseInstanceIds = caseInstanceIds;\n        } else {\n            this.caseInstanceIds = caseInstanceIds;","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L296-L332","documentation":"caseInstanceId(String) throws FlowableIllegalArgumentException when given null. A null case-instance id cannot be used as a query filter, so the engine fails fast at the setter instead of producing invalid SQL.","triggerScenarios":"Calling caseInstanceId(null) when the id variable came from an unpopulated variable, an optional path parameter, or a failed lookup.","commonSituations":"REST handlers passing path variables that are absent; chaining queries where a prior result returned no id.","solutions":["Pass a valid case instance id string.","Guard the call with a null check when the id is optional.","Catch FlowableIllegalArgumentException and surface a validation message."],"exampleFix":"// before\nquery.caseInstanceId(variables.get(\"caseInstanceId\"));\n// after\nString id = variables.get(\"caseInstanceId\");\nif (id != null) {\n    query.caseInstanceId(id);\n}","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null) { throw new IllegalArgumentException(\"caseInstanceId must not be null\"); }\nhistoricCaseInstanceQuery.caseInstanceId(caseInstanceId);","typeGuard":"boolean hasId(String id) { return id != null && !id.isEmpty(); }","tryCatchPattern":"try {\n    query.caseInstanceId(caseInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"caseInstanceId is required\", e);\n}","preventionTips":["Validate ids exist before constructing the query","Use Optional<String> to model possibly-absent ids","Never forward raw request parameters unchecked","Fail with a clear 400 message when a required id is missing"],"tags":["java","flowable","cmmn","null-argument","query-validation"],"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"}