{"record":{"id":"a36849b439c1c6fb","repo":"flowable/flowable-engine","slug":"parentscopeids-is-null-or-empty-a36849","errorCode":null,"errorMessage":"parentScopeIds is null or empty","messagePattern":"parentScopeIds is null or empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":741,"sourceCode":"            this.rootScopeIds = rootScopeIds;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processInstanceParentScopeId(String parentId) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.parentScopeId = parentId;\n        } else {\n            this.parentScopeId = parentId;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processInstanceParentScopeIds(Set<String> parentScopeIds) {\n        if (parentScopeIds == null || parentScopeIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"parentScopeIds is null or empty\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.parentScopeIds = parentScopeIds;\n        } else {\n            this.parentScopeIds = parentScopeIds;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery activeActivityId(String activityId) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.activeActivityId = activityId;\n        } else {\n            this.activeActivityId = activityId;\n        }\n        return this;\n    }","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ProcessInstanceQueryImpl.java#L723-L759","documentation":"ProcessInstanceQueryImpl.processInstanceParentScopeIds(Set<String>) filters process instances by parent scope IDs. Flowable throws FlowableIllegalArgumentException for a null or empty set, since an empty ID set yields an invalid empty IN clause in the generated SQL. The validation happens immediately in the fluent query method.","triggerScenarios":"Calling processInstanceParentScopeIds(null) or with an empty set, commonly when parent scope IDs were derived from a parent execution that no longer exists or from an empty collection of parent executions.","commonSituations":"Child-process queries where the parent lookup returned nothing; recursive hierarchy queries that hit a top-level instance with no parent; refactors that changed which collection gets passed.","solutions":["Call processInstanceParentScopeIds only with a non-empty set; otherwise omit the filter","Obtain valid parent scope IDs (e.g., via runtimeService) before building the query","Fix upstream parent-execution resolution logic","Catch FlowableIllegalArgumentException and handle the 'no parents' case explicitly"],"exampleFix":"// before\nquery.processInstanceParentScopeIds(parentScopeIds);\n// after\nif (parentScopeIds != null && !parentScopeIds.isEmpty()) {\n    query.processInstanceParentScopeIds(parentScopeIds);\n} else {\n    // handle no parent scopes (e.g., top-level query)\n}","handlingStrategy":"validation","validationCode":"if (parentScopeIds == null || parentScopeIds.isEmpty()) {\n    throw new IllegalArgumentException(\"At least one parent scope id is required\");\n}","typeGuard":"boolean hasParentScopeIds = parentScopeIds != null && !parentScopeIds.isEmpty();","tryCatchPattern":"try {\n    query.processInstanceParentScopeIds(parentScopeIds);\n} catch (FlowableIllegalArgumentException e) {\n    // treat as top-level query or empty result\n}","preventionTips":["Resolve parent executions before building child-instance queries","Guard optional filters with isEmpty checks","Add tests for hierarchy queries at the root level where parents are absent"],"tags":["flowable","process-instance-query","empty-collection","scope-ids"],"backgroundTag":"empty-required-field","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"}