{"record":{"id":"f8e9663ffe03a5d7","repo":"flowable/flowable-engine","slug":"set-of-process-instance-ids-is-empty-f8e966","errorCode":null,"errorMessage":"Set of process instance ids is empty","messagePattern":"Set of process instance ids is empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/HistoricActivityInstanceQueryImpl.java","lineNumber":98,"sourceCode":"\n    @Override\n    public List<HistoricActivityInstance> executeList(CommandContext commandContext) {\n        return CommandContextUtil.getHistoricActivityInstanceEntityManager(commandContext).findHistoricActivityInstancesByQueryCriteria(this);\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl processInstanceId(String processInstanceId) {\n        this.processInstanceId = processInstanceId;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl processInstanceIds(Set<String> processInstanceIds) {\n        if (processInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"Set of process instance ids is null\");\n        }\n        if (processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of process instance ids is empty\");\n        }\n        this.processInstanceIds = processInstanceIds;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl executionId(String executionId) {\n        this.executionId = executionId;\n        return this;\n    }\n\n    @Override\n    public HistoricActivityInstanceQueryImpl processDefinitionId(String processDefinitionId) {\n        this.processDefinitionId = processDefinitionId;\n        return this;\n    }\n\n    @Override","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/HistoricActivityInstanceQueryImpl.java#L80-L116","documentation":"HistoricActivityInstanceQueryImpl.processInstanceIds(Set<String>) also rejects an empty set with FlowableIllegalArgumentException. An empty set would translate to an impossible SQL IN () clause, so Flowable fails fast during query construction.","triggerScenarios":"Calling processInstanceIds(new HashSet<>()) or a set filtered down to zero elements (e.g. user selected no instances, or all ids were filtered out before the call).","commonSituations":"UI-driven reports where the user deselects all items; batch jobs whose id list is empty because no instances matched a prior step.","solutions":["Check !ids.isEmpty() before calling processInstanceIds; skip the filter or short-circuit to an empty result","Return an empty result early in application code when no ids were selected, avoiding the DB query entirely","Default to a non-filtering query when the set is empty, if 'all instances' is the intended meaning"],"exampleFix":"// before\nSet<String> ids = selectedIds.stream().filter(this::valid).collect(toSet());\nquery.processInstanceIds(ids);\n\n// after\nSet<String> ids = selectedIds.stream().filter(this::valid).collect(toSet());\nif (!ids.isEmpty()) {\n    query.processInstanceIds(ids);\n} else {\n    return Collections.emptyList();\n}","handlingStrategy":"validation","validationCode":"if (ids != null && !ids.isEmpty()) {\n    query.processInstanceIds(ids);\n} else {\n    return Collections.emptyList();\n}","typeGuard":"boolean isNonEmptySet(Set<String> s) { return s != null && !s.isEmpty(); }","tryCatchPattern":"try {\n    query.processInstanceIds(ids);\n} catch (FlowableIllegalArgumentException e) {\n    if (!e.getMessage().contains(\"Set of process instance ids is empty\")) throw e;\n    // short-circuit: no ids selected means no results\n}","preventionTips":["Short-circuit to an empty result when the selection is empty","Filter ids before building the query and branch on the resulting size"],"tags":["flowable","query","empty-collection","history","java"],"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-14T11:17:12.474Z"}