{"record":{"id":"aaadb899e76f976a","repo":"flowable/flowable-engine","slug":"processinstanceids-is-empty-aaadb8","errorCode":null,"errorMessage":"processInstanceIds is empty","messagePattern":"processInstanceIds is empty","errorType":"validation","errorClass":"org.flowable.common.engine.api.FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java","lineNumber":92,"sourceCode":"    @Override\n    public HistoricVariableInstanceQuery id(String id) {\n        this.id = id;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQueryImpl processInstanceId(String processInstanceId) {\n        if (processInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"processInstanceId is null\");\n        }\n        this.processInstanceId = processInstanceId;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQuery processInstanceIds(Collection<String> processInstanceIds) {\n        if (processInstanceIds == null || processInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"processInstanceIds is empty\");\n        }\n        this.processInstanceIds = processInstanceIds;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQueryImpl executionId(String executionId) {\n        if (executionId == null) {\n            throw new FlowableIllegalArgumentException(\"Execution id is null\");\n        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use executionId together with excludeLocalVariables\");\n        }\n        this.executionId = executionId;\n        return this;\n    }\n\n    @Override","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/HistoricVariableInstanceQueryImpl.java#L74-L110","documentation":"HistoricVariableInstanceQueryImpl.processInstanceIds requires a non-null, non-empty collection and throws FlowableIllegalArgumentException when the collection is null or empty. An empty IN clause would generate invalid SQL, so the builder validates eagerly. This error occurs at query-construction time.","triggerScenarios":"Calling createHistoricVariableInstanceQuery().processInstanceIds(Collections.emptyList()) or processInstanceIds(null), commonly when the id list comes from an upstream query that matched nothing.","commonSituations":"Batch lookups where the previous query returned zero rows; request parameters with no selected instances; building queries in loops that start with an empty accumulator.","solutions":["Skip the query (or return an empty result directly) when the collection is empty","Only add the processInstanceIds clause when the collection has elements","Ensure the upstream query that produces the ids actually matches expected data","Defensively default to a sentinel if querying all instances is intended (or use no clause)"],"exampleFix":"// before\nquery.processInstanceIds(ids);\n// after\nif (ids != null && !ids.isEmpty()) {\n    query.processInstanceIds(ids);\n} else {\n    return Collections.emptyList();\n}","handlingStrategy":"validation","validationCode":"if (ids == null || ids.isEmpty()) {\n    return Collections.emptyList(); // nothing to query\n}\nquery.processInstanceIds(ids);","typeGuard":"static boolean hasIds(Collection<String> ids) {\n    return ids != null && !ids.isEmpty();\n}","tryCatchPattern":"try {\n    query.processInstanceIds(ids);\n} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {\n    // return empty result set for empty input\n}","preventionTips":["Treat empty id lists as 'no results', not 'all results'","Check upstream queries for zero matches before batch lookups","Wrap collection-based clauses in helper methods that handle empty input","Add early returns for empty collections in service code"],"tags":["flowable","query","empty-collection","history"],"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"}