{"record":{"id":"5971013f75aec90f","repo":"flowable/flowable-engine","slug":"rootscopeids-is-null-or-empty","errorCode":null,"errorMessage":"rootScopeIds is null or empty","messagePattern":"rootScopeIds 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/history/HistoricCaseInstanceQueryImpl.java","lineNumber":422,"sourceCode":"    }\n    \n    @Override\n    public HistoricCaseInstanceQueryImpl caseInstanceRootScopeId(String rootScopeId) {\n        if (rootScopeId == null) {\n            throw new FlowableIllegalArgumentException(\"rootScopeId is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.rootScopeId = rootScopeId;\n        } else {\n            this.rootScopeId = rootScopeId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery caseInstanceRootScopeIds(Set<String> rootScopeIds) {\n        if (rootScopeIds == null || rootScopeIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"rootScopeIds is null or empty\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.rootScopeIds = rootScopeIds;\n        } else {\n            this.rootScopeIds = rootScopeIds;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQueryImpl 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;","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L404-L440","documentation":"caseInstanceRootScopeIds(Set<String>) throws 'rootScopeIds is null or empty' when the set is null or has no elements. Unlike most setters that only reject null, this one also rejects an empty set, so callers must supply at least one root scope id.","triggerScenarios":"Calling caseInstanceRootScopeIds(null) or caseInstanceRootScopeIds(new HashSet<>()) / an empty collection produced by filtering.","commonSituations":"Dynamic filter builders that collect selected root scopes from UI selections where nothing was selected; stream filters that removed all entries.","solutions":["Ensure the set contains at least one id before calling.","Skip the setter entirely (no root-scope filter) when the set is empty.","Catch FlowableIllegalArgumentException and return a 'select at least one scope' validation message."],"exampleFix":"// before\nquery.caseInstanceRootScopeIds(selectedRootIds); // may be null/empty\n// after\nif (selectedRootIds != null && !selectedRootIds.isEmpty()) {\n    query.caseInstanceRootScopeIds(selectedRootIds);\n}","handlingStrategy":"validation","validationCode":"if (rootScopeIds == null || rootScopeIds.isEmpty()) { throw new IllegalArgumentException(\"rootScopeIds must contain at least one id\"); }\nhistoricCaseInstanceQuery.caseInstanceRootScopeIds(rootScopeIds);","typeGuard":"boolean hasRootScopeIds(Set<String> ids) { return ids != null && !ids.isEmpty(); }","tryCatchPattern":"try {\n    query.caseInstanceRootScopeIds(rootScopeIds);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"At least one root scope id is required\", e);\n}","preventionTips":["Remember this setter rejects empty sets, unlike most others","Skip the filter entirely when no root scopes are selected","Guard against empty results from stream/filter operations","Return a clear validation message when a selection is required"],"tags":["java","flowable","cmmn","null-argument","empty-collection","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-14T11:17:12.474Z"}