{"record":{"id":"12c03e2679421d53","repo":"flowable/flowable-engine","slug":"parentscopeids-is-null-or-empty-12c03e","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-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/CaseInstanceQueryImpl.java","lineNumber":412,"sourceCode":"    }\n\n    @Override\n    public CaseInstanceQuery caseInstanceParentScopeId(String parentScopeId) {\n        if (parentScopeId == null) {\n            throw new FlowableIllegalArgumentException(\"parentScopeId is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.parentScopeId = parentScopeId;\n        } else {\n            this.parentScopeId = parentScopeId;\n        }\n        return this;\n    }\n\n    @Override\n    public CaseInstanceQuery caseInstanceParentScopeIds(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 CaseInstanceQueryImpl caseInstanceBusinessKey(String businessKey) {\n        if (businessKey == null) {\n            throw new FlowableIllegalArgumentException(\"Business key is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.businessKey = businessKey;\n        } else {\n            this.businessKey = businessKey;","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/CaseInstanceQueryImpl.java#L394-L430","documentation":"Flowable's CaseInstanceQueryImpl throws FlowableIllegalArgumentException when caseInstanceParentScopeIds(Set<String>) is called with a null or empty set. An empty IN-list has no valid SQL semantics for this filter, so the query API validates the argument up front. At least one parent scope id must be supplied.","triggerScenarios":"Calling caseInstanceParentScopeIds(null), an empty Set/Collections.emptySet(), or a set derived from filtering that ended up empty before executing the case instance query.","commonSituations":"Batch queries where the parent scope ids were collected from a prior query that returned no rows; passing an empty HashSet initialized but never filled; refactoring from single caseInstanceParentScopeId to plural and forgetting to populate; parallel test runs with no scope data.","solutions":["Only call the method when the set contains at least one id; otherwise skip the criterion","Validate the upstream collection (parent scope lookup) that should have produced the ids","Fall back to caseInstanceParentScopeId for the single-id case if that is what you have","If no filtering is desired, do not add the parent-scope criterion at all"],"exampleFix":"// before\nquery.caseInstanceParentScopeIds(parentScopeIds); // may be null/empty\n// after\nif (parentScopeIds != null && !parentScopeIds.isEmpty()) {\n    query.caseInstanceParentScopeIds(parentScopeIds);\n}","handlingStrategy":"validation","validationCode":"if (parentScopeIds == null || parentScopeIds.isEmpty()) {\n    throw new IllegalArgumentException(\"parentScopeIds must contain at least one id\");\n}\nquery.caseInstanceParentScopeIds(parentScopeIds);","typeGuard":"boolean hasParentScopeIds(Set<String> ids) {\n    return ids != null && !ids.isEmpty();\n}","tryCatchPattern":"try {\n    query.caseInstanceParentScopeIds(parentScopeIds);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid parent scope ids: {}\", e.getMessage());\n    throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"parentScopeIds must not be empty\");\n}","preventionTips":["Check both null and isEmpty on collection arguments for plural filter methods","Handle empty upstream lookups before query construction","Use the single-id variant when only one parent scope is targeted","Cover empty-collection cases in query-builder unit tests"],"tags":["flowable","cmmn","query","null-check","validation"],"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-14T05:17:10.506Z"}