{"record":{"id":"77df4d8224b38d58","repo":"flowable/flowable-engine","slug":"taskids-is-null-or-empty","errorCode":null,"errorMessage":"taskIds is null or empty","messagePattern":"taskIds is null or 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/InternalVariableInstanceQueryImpl.java","lineNumber":82,"sourceCode":"\n    @Override\n    public InternalVariableInstanceQuery taskId(String taskId) {\n        if (StringUtils.isEmpty(taskId)) {\n            throw new FlowableIllegalArgumentException(\"taskId is empty\");\n        }\n\n        if (withoutTaskId) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine taskId(String) with withoutTaskId() in the same query\");\n        }\n\n        this.taskId = taskId;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery taskIds(Collection<String> taskIds) {\n        if (taskIds == null || taskIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"taskIds is null or empty\");\n        }\n\n        if (withoutTaskId) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine taskIds(Collection) with withoutTaskId() in the same query\");\n        }\n        this.taskIds = taskIds;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery processInstanceId(String processInstanceId) {\n        if (StringUtils.isEmpty(processInstanceId)) {\n            throw new FlowableIllegalArgumentException(\"processInstanceId is empty\");\n        }\n        this.processInstanceId = processInstanceId;\n        return this;\n    }\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java#L64-L100","documentation":"InternalVariableInstanceQueryImpl.taskIds(Collection<String>) throws FlowableIllegalArgumentException when the collection is null or empty. An empty IN-clause would be invalid SQL or would silently match nothing, so the builder fails fast. Callers must pass a collection containing at least one task id.","triggerScenarios":"Calling taskIds(null), taskIds(Collections.emptyList()), or taskIds of a collection produced by an empty stream/filter result.","commonSituations":"Collecting task ids from a prior query that returned no rows; building bulk variable lookups where the id list comes from an empty request payload.","solutions":["Check collection size and skip the query entirely when empty","Ensure the upstream task-id list is populated before building the query","If 'no tasks' is a valid state, return an empty result without executing the query"],"exampleFix":"// before\nquery.taskIds(taskIds); // throws when list is empty\n// after\nif (taskIds == null || taskIds.isEmpty()) {\n    return Collections.emptyList();\n}\nquery.taskIds(taskIds);","handlingStrategy":"validation","validationCode":"if (taskIds == null || taskIds.isEmpty()) { return Collections.emptyList(); }","typeGuard":"boolean hasItems(Collection<?> c) { return c != null && !c.isEmpty(); }","tryCatchPattern":"try { query.taskIds(taskIds); } catch (FlowableIllegalArgumentException e) { log.warn(\"taskIds collection empty; returning no variables\", e); return Collections.emptyList(); }","preventionTips":["Short-circuit bulk queries when the id list is empty","Check upstream queries for empty results before using their ids","Add unit tests covering empty-collection inputs to query helpers"],"tags":["flowable","query-builder","empty-collection","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"}