{"record":{"id":"8693fae05441c9f6","repo":"flowable/flowable-engine","slug":"set-of-process-instance-ids-is-empty-8693fa","errorCode":null,"errorMessage":"Set of process instance ids is empty","messagePattern":"Set of process instance ids is empty","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":115,"sourceCode":"    public ProcessInstanceQueryImpl processInstanceId(String processInstanceId) {\n        if (processInstanceId == null) {\n            throw new ActivitiIllegalArgumentException(\"Process instance id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.executionId = processInstanceId;\n        } else {\n            this.executionId = processInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processInstanceIds(Set<String> processInstanceIds) {\n        if (processInstanceIds == null) {\n            throw new ActivitiIllegalArgumentException(\"Set of process instance ids is null\");\n        }\n        if (processInstanceIds.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"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 ProcessInstanceQuery processInstanceBusinessKey(String businessKey) {\n        if (businessKey == null) {\n            throw new ActivitiIllegalArgumentException(\"Business key is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.businessKey = businessKey;\n        } else {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java#L97-L133","documentation":"processInstanceIds(Set) additionally throws ActivitiIllegalArgumentException('Set of process instance ids is empty') when the provided set has no elements, because an IN () clause is invalid and would silently match nothing.","triggerScenarios":"Calling ProcessInstanceQuery.processInstanceIds(new HashSet<>()) or passing a set that was emptied by upstream filtering (e.g. intersection of permissions produced zero ids).","commonSituations":"Filter UIs where the user deselects all ids; permission-intersection code that legitimately yields an empty set but still issues the query.","solutions":["Short-circuit: if the set is empty, return an empty result without executing the query","Ensure upstream collection logic always leaves at least one id, or handle the empty case explicitly","Use processInstanceId() for the single-id case after confirming size()==1 if appropriate","Catch ActivitiIllegalArgumentException and treat it as 'no matches'"],"exampleFix":"// before\nruntimeService.createProcessInstanceQuery().processInstanceIds(ids).list();\n// after\nif (ids == null || ids.isEmpty()) {\n    return Collections.emptyList();\n}\nruntimeService.createProcessInstanceQuery().processInstanceIds(ids).list();","handlingStrategy":"validation","validationCode":"if (ids == null || ids.isEmpty()) {\n    return Collections.emptyList(); // skip query entirely\n}\nquery.processInstanceIds(ids);","typeGuard":"boolean isNonEmptyCollection(Collection<String> c) { return c != null && !c.isEmpty(); }","tryCatchPattern":"try {\n    query.processInstanceIds(ids);\n} catch (ActivitiIllegalArgumentException e) {\n    return Collections.emptyList(); // treat empty as no matches\n}","preventionTips":["Guard all IN-style query inputs for emptiness before execution","Handle permission-intersection results that can legitimately be empty","Prefer skipping the engine call over issuing an invalid query"],"tags":["java","activiti","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"}