{"record":{"id":"bdc4d095137a53ee","repo":"flowable/flowable-engine","slug":"parent-case-instance-id-is-null","errorCode":null,"errorMessage":"parent case instance id is null","messagePattern":"parent case instance id is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java","lineNumber":770,"sourceCode":"    }\n    \n    @Override\n    public HistoricCaseInstanceQuery caseInstanceCallbackType(String callbackType) {\n        if (callbackType == null) {\n            throw new FlowableIllegalArgumentException(\"callback type is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.callbackType = callbackType;\n        } else {\n            this.callbackType = callbackType;\n        }\n        return this;\n    }\n    \n    @Override\n    public HistoricCaseInstanceQuery parentCaseInstanceId(String parentCaseInstanceId) {\n        if (parentCaseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"parent case instance id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.parentCaseInstanceId = parentCaseInstanceId;\n        } else {\n            this.parentCaseInstanceId = parentCaseInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery parentProcessInstanceId(String parentProcessInstanceId) {\n        if (parentProcessInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"parentProcessInstanceId is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.parentProcessInstanceId = parentProcessInstanceId;\n        } else {\n            this.parentProcessInstanceId = parentProcessInstanceId;","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L752-L788","documentation":"HistoricCaseInstanceQueryImpl.parentCaseInstanceId(String) requires a non-null parent case instance id, since it is used as a direct equality predicate on the parentCaseInstanceId column. A null argument cannot be translated into a valid SQL condition, so a FlowableIllegalArgumentException is thrown immediately.","triggerScenarios":"Calling parentCaseInstanceId(null) on a HistoricCaseInstanceQuery; commonly when the parent id variable was never set or a lookup of the parent case instance returned null.","commonSituations":"Querying children of a case instance whose parent id was resolved via an API call that returned null (e.g. root case instances have no parent); iterating a map of parent ids that contains a null entry.","solutions":["Pass a valid, existing parent case instance id string.","If you want root cases, use caseInstanceParentIdIsNull()/the parent-null variant instead of passing null.","Guard the call with a null check and skip the parent filter when the id is unknown."],"exampleFix":"// before\nquery.parentCaseInstanceId(parentId); // parentId may be null for root cases\n// after\nif (parentId != null) {\n    query.parentCaseInstanceId(parentId);\n} else {\n    query.caseInstanceWithoutParent(); // or omit the filter\n}","handlingStrategy":"validation","validationCode":"if (parentCaseInstanceId != null) {\n    query.parentCaseInstanceId(parentCaseInstanceId);\n} // else: omit parent filter or use the parent-is-null variant for root cases","typeGuard":"boolean isSet(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.parentCaseInstanceId(parentId);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"No parent filter applied: {}\", e.getMessage());\n}","preventionTips":["Remember root case instances have no parent — handle the null parent case explicitly.","Resolve parent ids with a null-safe lookup before building queries.","Apply conditional filter-building instead of unconditional chaining."],"tags":["null-argument","query","cmmn","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-18T11:17:12.947Z"}