{"record":{"id":"e304136c704f9ee0","repo":"Activiti/Activiti","slug":"process-instance-id-list-is-empty","errorCode":null,"errorMessage":"Process instance id list is empty","messagePattern":"Process instance id list is empty","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":175,"sourceCode":"        return tasks;\n    }\n\n    public HistoricTaskInstanceQueryImpl 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 HistoricTaskInstanceQueryImpl processInstanceIdIn(List<String> processInstanceIds) {\n        if (processInstanceIds == null) {\n            throw new ActivitiIllegalArgumentException(\"Process instance id list is null\");\n        }\n        if (processInstanceIds.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Process instance id list is empty\");\n        }\n        for (String processInstanceId : processInstanceIds) {\n            if (processInstanceId == null) {\n                throw new ActivitiIllegalArgumentException(\"None of the given process instance ids can be null\");\n            }\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processInstanceIds = processInstanceIds;\n        } else {\n            this.processInstanceIds = processInstanceIds;\n        }\n        return this;\n    }\n\n    public HistoricTaskInstanceQueryImpl processInstanceBusinessKey(String processInstanceBusinessKey) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.processInstanceBusinessKey = processInstanceBusinessKey;","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java#L157-L193","documentation":"HistoricTaskInstanceQueryImpl.processInstanceIdIn() throws ActivitiIllegalArgumentException when the processInstanceIds list is empty. Like the null case, an empty list cannot produce a valid IN clause and would misleadingly return no tasks, so the library treats it as a programming error.","triggerScenarios":"Calling processInstanceIdIn(new ArrayList<>()) or passing a list emptied by filtering; piping in ids from a previous query that returned zero rows.","commonSituations":"Batch correlation flows where the source query matched nothing; dynamic filters from user selection UIs with nothing selected; pagination logic draining the list before the query runs.","solutions":["Ensure the list contains at least one process instance id","Return an empty result early when the list is empty instead of executing the query","Drop the processInstanceIdIn() filter when no id restriction is intended","Validate the upstream id-collection step so it cannot silently produce an empty list"],"exampleFix":"// before\nquery.processInstanceIdIn(collectProcessInstanceIds()); // empty -> throws\n// after\nList<String> pids = collectProcessInstanceIds();\nif (pids.isEmpty()) {\n    return Collections.emptyList();\n}\nquery.processInstanceIdIn(pids);","handlingStrategy":"validation","validationCode":"if (processInstanceIds == null || processInstanceIds.isEmpty()) {\n    return Collections.emptyList();\n}\ntaskQuery.processInstanceIdIn(processInstanceIds);","typeGuard":"boolean isPopulatedList(java.util.List<?> l) { return l != null && !l.isEmpty(); }","tryCatchPattern":"try {\n    query.processInstanceIdIn(pids);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    if (!e.getMessage().contains(\"Process instance id list is empty\")) throw e;\n    return Collections.emptyList();\n}","preventionTips":["Return early with an empty result when the id list is empty","Also guard list elements: null elements in the list are rejected separately","Test dynamic query paths with empty input lists"],"tags":["activiti","query-builder","empty-collection","task-query"],"backgroundTag":"empty-required-field","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}