{"record":{"id":"090500e5d3e47703","repo":"flowable/flowable-engine","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":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":304,"sourceCode":"    }\n\n    @Override\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(Collection<String> processInstanceIds) {\n        if (processInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"Process instance id list is null\");\n        }\n        if (processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Process instance id list is empty\");\n        }\n        for (String processInstanceId : processInstanceIds) {\n            if (processInstanceId == null) {\n                throw new FlowableIllegalArgumentException(\"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    @Override\n    public HistoricTaskInstanceQueryImpl withoutProcessInstanceId() {\n        if (inOrStatement) {","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java#L286-L322","documentation":"HistoricTaskInstanceQueryImpl.processInstanceIdIn(Collection<String>) rejects an empty collection with FlowableIllegalArgumentException('Process instance id list is empty') because an IN predicate over zero values would produce invalid/meaningless SQL. The caller must supply at least one process instance id.","triggerScenarios":"Calling processInstanceIdIn(Collections.emptyList()) or a list that was filtered down to zero elements right before the query executes.","commonSituations":"Collecting candidate process instance ids upstream (e.g. from a search that matched nothing) and passing the empty result straight into the query; over-aggressive filtering removing all ids.","solutions":["Skip adding the predicate when the list is empty and return no results directly (an IN () can never match).","Only call processInstanceIdIn when !ids.isEmpty(); otherwise short-circuit to an empty result page.","Fix upstream filtering that unintentionally removes all ids."],"exampleFix":"// before\nquery.processInstanceIdIn(candidateIds); // candidateIds may be empty -> exception\n\n// after\nif (candidateIds.isEmpty()) {\n    return Collections.emptyList(); // no instances -> no tasks can match\n}\nquery.processInstanceIdIn(candidateIds);","handlingStrategy":"validation","validationCode":"if (processInstanceIds == null || processInstanceIds.isEmpty()) {\n    return Collections.emptyList(); // IN () can never match\n}","typeGuard":"boolean isUsableIdList(Collection<String> c) { return c != null && !c.isEmpty(); }","tryCatchPattern":null,"preventionTips":["Short-circuit queries when the candidate id set is empty","Treat empty filter lists as 'no results' semantics explicitly in your service layer","Guard against over-filtering that silently empties id lists"],"tags":["query","empty-collection","task-history","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-18T11:17:12.947Z"}