{"record":{"id":"20b10f814e30c153","repo":"flowable/flowable-engine","slug":"process-instance-id-list-is-empty-20b10f","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":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java","lineNumber":623,"sourceCode":"    }\n\n    @Override\n    public TaskQueryImpl processInstanceId(String processInstanceId) {\n        if (orActive) {\n            currentOrQueryObject.processInstanceId = processInstanceId;\n        } else {\n            this.processInstanceId = processInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQuery 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 (orActive) {\n            currentOrQueryObject.processInstanceIds = processInstanceIds;\n        } else {\n            this.processInstanceIds = processInstanceIds;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQueryImpl processInstanceBusinessKey(String processInstanceBusinessKey) {\n        if (orActive) {","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java#L605-L641","documentation":"TaskQueryImpl.processInstanceIdIn(List<String>) throws ActivitiIllegalArgumentException when the processInstanceIds list is empty. An empty IN list would yield invalid SQL (IN ()), so the engine rejects it eagerly when the query is built rather than at execution time.","triggerScenarios":"Calling taskQuery.processInstanceIdIn(new ArrayList<>()) or passing a filtered collection with zero remaining ids.","commonSituations":"No process instances matched a preceding lookup (e.g. all completed/canceled), so the id list arrives empty; business code then builds the query unconditionally.","solutions":["Check isEmpty() before calling processInstanceIdIn and short-circuit to an empty result instead of querying.","Centralize the null/empty guard in a query helper shared by all task queries.","Catch ActivitiIllegalArgumentException and translate it into 'no process instances selected' for the client."],"exampleFix":"// before\ntaskQuery.processInstanceIdIn(instanceIds); // may be empty\n\n// after\nif (instanceIds == null || instanceIds.isEmpty()) {\n    return Collections.emptyList();\n}\ntaskQuery.processInstanceIdIn(instanceIds);","handlingStrategy":"validation","validationCode":"if (processInstanceIds == null || processInstanceIds.isEmpty()) {\n    return Collections.emptyList();\n}\ntaskQuery.processInstanceIdIn(processInstanceIds);","typeGuard":"boolean isUsableIdList(List<String> ids) { return ids != null && !ids.isEmpty(); }","tryCatchPattern":"try {\n    return taskQuery.processInstanceIdIn(ids).list();\n} catch (ActivitiIllegalArgumentException e) {\n    log.warn(\"Empty id list rejected: {}\", e.getMessage());\n    return Collections.emptyList();\n}","preventionTips":["Short-circuit to empty results when the id list is empty by construction","Check filter state before assembling queries","Reuse a shared guard helper across all in-list filters"],"tags":["activiti","flowable","task-query","argument-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"}