flowable/flowable-engine · error · org.flowable.common.engine.api.FlowableIllegalArgumentException

taskIds is null or empty

Error message

taskIds is null or empty

What it means

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.

Solutions

  1. Check collection size and skip the query entirely when empty
  2. Ensure the upstream task-id list is populated before building the query
  3. If 'no tasks' is a valid state, return an empty result without executing the query

Example fix

// before
query.taskIds(taskIds); // throws when list is empty
// after
if (taskIds == null || taskIds.isEmpty()) {
    return Collections.emptyList();
}
query.taskIds(taskIds);
Defensive patterns

Strategy: validation

Validate before calling

if (taskIds == null || taskIds.isEmpty()) { return Collections.emptyList(); }

Type guard

boolean hasItems(Collection<?> c) { return c != null && !c.isEmpty(); }

Try / catch

try { query.taskIds(taskIds); } catch (FlowableIllegalArgumentException e) { log.warn("taskIds collection empty; returning no variables", e); return Collections.emptyList(); }

Prevention

When it happens

Trigger: Calling taskIds(null), taskIds(Collections.emptyList()), or taskIds of a collection produced by an empty stream/filter result.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/77df4d8224b38d58. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java:82

    @Override
    public InternalVariableInstanceQuery taskId(String taskId) {
        if (StringUtils.isEmpty(taskId)) {
            throw new FlowableIllegalArgumentException("taskId is empty");
        }

        if (withoutTaskId) {
            throw new FlowableIllegalArgumentException("Cannot combine taskId(String) with withoutTaskId() in the same query");
        }

        this.taskId = taskId;
        return this;
    }

    @Override
    public InternalVariableInstanceQuery taskIds(Collection<String> taskIds) {
        if (taskIds == null || taskIds.isEmpty()) {
            throw new FlowableIllegalArgumentException("taskIds is null or empty");
        }

        if (withoutTaskId) {
            throw new FlowableIllegalArgumentException("Cannot combine taskIds(Collection) with withoutTaskId() in the same query");
        }
        this.taskIds = taskIds;
        return this;
    }

    @Override
    public InternalVariableInstanceQuery processInstanceId(String processInstanceId) {
        if (StringUtils.isEmpty(processInstanceId)) {
            throw new FlowableIllegalArgumentException("processInstanceId is empty");
        }
        this.processInstanceId = processInstanceId;
        return this;
    }

View on GitHub (pinned to d6d39ce1c6)