{"record":{"id":"bb42cd450f873326","repo":"flowable/flowable-engine","slug":"set-of-process-instance-ids-is-empty-bb42cd","errorCode":null,"errorMessage":"Set of process instance ids is empty","messagePattern":"Set of process instance ids is empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/HistoricProcessInstanceQueryImpl.java","lineNumber":164,"sourceCode":"    }\n\n    @Override\n    public HistoricProcessInstanceQueryImpl processInstanceId(String processInstanceId) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.processInstanceId = processInstanceId;\n        } else {\n            this.processInstanceId = processInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricProcessInstanceQuery processInstanceIds(Set<String> processInstanceIds) {\n        if (processInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"Set of process instance ids is null\");\n        }\n        if (processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of process instance ids is empty\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processInstanceIds = processInstanceIds;\n        } else {\n            this.processInstanceIds = processInstanceIds;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricProcessInstanceQueryImpl processDefinitionId(String processDefinitionId) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionId = processDefinitionId;\n        } else {\n            this.processDefinitionId = processDefinitionId;\n        }\n        return this;","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/HistoricProcessInstanceQueryImpl.java#L146-L182","documentation":"Flowable's HistoricProcessInstanceQuery.processInstanceIds(Set<String>) rejects empty sets. An empty id set would produce an impossible or unbounded SQL IN clause, so the API throws FlowableIllegalArgumentException at query-build time. Callers must supply at least one process instance id.","triggerScenarios":"Calling processInstanceIds(ids) where ids is a non-null but empty Set — e.g. new HashSet<>() passed directly, or a filtered collection that ended up with zero elements.","commonSituations":"Filtering results upstream removed all entries before the query was built; initializing a set but never populating it; paging logic that produced an empty batch of ids.","solutions":["Populate the set with at least one id before calling processInstanceIds","Guard the call with !ids.isEmpty() and skip/alter the query when empty","Decide on explicit behavior for the empty case: return no results early instead of executing the query","Use a different query criterion entirely when no ids are known"],"exampleFix":"// before\nquery.processInstanceIds(ids); // throws when ids.isEmpty()\n// after\nif (ids != null && !ids.isEmpty()) {\n    query.processInstanceIds(ids);\n} else {\n    return Collections.emptyList();\n}","handlingStrategy":"validation","validationCode":"if (ids == null || ids.isEmpty()) {\n    return Collections.emptyList(); // nothing to query\n}\nquery.processInstanceIds(ids);","typeGuard":"boolean hasElements(Set<String> s) {\n    return s != null && !s.isEmpty();\n}","tryCatchPattern":"try {\n    query.processInstanceIds(ids);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"empty\")) {\n        return Collections.emptyList();\n    }\n    throw e;\n}","preventionTips":["Check isEmpty() before building IN-style criteria","Short-circuit to an empty result when no ids are known","Add unit tests covering the empty-collection path","Avoid returning freshly allocated empty sets from id-collection methods without callers checking"],"tags":["flowable","empty-collection","query-validation","java"],"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"}