{"record":{"id":"e4fd293e20a1868d","repo":"flowable/flowable-engine","slug":"process-instance-id-list-is-empty-e4fd29","errorCode":null,"errorMessage":"Process instance id list is empty","messagePattern":"Process instance id list is empty","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":165,"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(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    @Override\n    public HistoricTaskInstanceQueryImpl processInstanceBusinessKey(String processInstanceBusinessKey) {\n        if (inOrStatement) {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java#L147-L183","documentation":"HistoricTaskInstanceQueryImpl.processInstanceIdIn() throws ActivitiIllegalArgumentException when the supplied process instance id list is non-null but empty. The library requires at least one id because an SQL IN clause with no values would be invalid or return nothing. Pass a non-empty list of process instance ids.","triggerScenarios":"Calling historicTaskInstanceQuery.processInstanceIdIn(new ArrayList<>()) (or any empty List<String>) on the query object.","commonSituations":"Building the id list dynamically from an upstream search that matched nothing; passing a collection that was filtered to empty; wiring a default empty collection into query construction.","solutions":["Ensure the list passed to processInstanceIdIn contains at least one process instance id before building the query.","If the id list may be empty, skip the query or use a different filter entirely instead of calling processInstanceIdIn.","Guard the call with a size check: if (ids != null && !ids.isEmpty()) query.processInstanceIdIn(ids);"],"exampleFix":"// before\nList<String> ids = collectIds(); // may be empty\nquery.processInstanceIdIn(ids);\n\n// after\nList<String> ids = collectIds();\nif (!ids.isEmpty()) {\n    query.processInstanceIdIn(ids);\n} else {\n    return Collections.emptyList(); // no candidates, skip query\n}","handlingStrategy":"validation","validationCode":"if (processInstanceIds == null || processInstanceIds.isEmpty()) { throw new IllegalArgumentException(\"processInstanceIds must contain at least one id\"); }\nfor (String id : processInstanceIds) { if (id == null) { throw new IllegalArgumentException(\"processInstanceIds must not contain nulls\"); } }","typeGuard":"static boolean isUsableIdList(List<String> ids) { return ids != null && !ids.isEmpty() && ids.stream().allMatch(Objects::nonNull); }","tryCatchPattern":"try {\n    query.processInstanceIdIn(ids);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    log.warn(\"Invalid processInstanceIdIn argument: {}\", e.getMessage());\n    // fall back to unfiltered query or return empty result\n}","preventionTips":["Never call *In(...) query methods with collections that may be empty; gate them behind size checks.","Normalize collections (remove nulls, require non-empty) in one shared query-builder helper.","Write unit tests covering empty/null lists for every query filter you use."],"tags":["java","activiti","query-validation","illegal-argument"],"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"}