{"record":{"id":"70f697b423681684","repo":"flowable/flowable-engine","slug":"scopeids-is-empty-70f697","errorCode":null,"errorMessage":"scopeIds is empty","messagePattern":"scopeIds is empty","errorType":"validation","errorClass":"org.flowable.common.engine.api.FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java","lineNumber":260,"sourceCode":"    @Override\n    public HistoricVariableInstanceQuery variableNameLike(String variableNameLike) {\n        if (variableNameLike == null) {\n            throw new FlowableIllegalArgumentException(\"variableNameLike is null\");\n        }\n        this.variableNameLike = variableNameLike;\n        return this;\n    }\n    \n    @Override\n    public HistoricVariableInstanceQuery scopeId(String scopeId) {\n        this.scopeId = scopeId;\n        return this;\n    }\n    \n    @Override\n    public HistoricVariableInstanceQuery scopeIds(Collection<String> scopeIds) {\n        if (scopeIds == null || scopeIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"scopeIds is empty\");\n        }\n        this.scopeIds = scopeIds;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQuery subScopeId(String subScopeId) {\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use subScopeId together with excludeLocalVariables\");\n        }\n\n        this.subScopeId = subScopeId;\n        return this;\n    }\n    \n    @Override\n    public HistoricVariableInstanceQuery scopeType(String scopeType) {\n        this.scopeType = scopeType;","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java#L242-L278","documentation":"HistoricVariableInstanceQuery.scopeIds() throws FlowableIllegalArgumentException when the scopeIds collection is null or empty. Querying by scope ids is only meaningful with at least one id, so an empty collection is rejected rather than producing an IN () SQL fragment that would fail or match nothing.","triggerScenarios":"Calling historicVariableInstanceQuery.scopeIds(null) or scopeIds(Collections.emptyList()) / a list that ended up empty after filtering.","commonSituations":"Collecting task or execution ids into a list that turns out empty (e.g. a user with no tasks) and passing it directly; a batch job with nothing to process still invoking the query; null returned from an upstream lookup.","solutions":["Ensure at least one scope id is in the collection before calling scopeIds.","Short-circuit: if the collection is null/empty, skip the query entirely and return an empty result.","Guard with if (scopeIds != null && !scopeIds.isEmpty()) before building the query.","If you meant a single scope, use scopeId(String) instead of building a one-element collection incorrectly."],"exampleFix":"// before\nquery.scopeIds(taskIds);\n\n// after\nif (taskIds != null && !taskIds.isEmpty()) {\n    query.scopeIds(taskIds);\n} else {\n    return Collections.emptyList();\n}","handlingStrategy":"validation","validationCode":"if (scopeIds == null || scopeIds.isEmpty()) {\n    return Collections.emptyList(); // nothing to query\n}","typeGuard":null,"tryCatchPattern":"try {\n    query.scopeIds(scopeIds);\n} catch (FlowableIllegalArgumentException e) {\n    return Collections.emptyList();\n}","preventionTips":["Treat an empty id collection as an empty result, not a query input.","Check collection size after any filtering/transformation that could empty it.","Use scopeId(String) for the single-id case to avoid needless collection wrapping."],"tags":["flowable","query","empty-collection","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"}