flowable/flowable-engine · error · FlowableIllegalArgumentException

Task id list is empty

Error message

Task id list is empty

What it means

HistoricTaskInstanceQueryImpl.taskIds(Collection) throws FlowableIllegalArgumentException when the collection is non-null but empty. An empty ID list would yield invalid or meaningless IN-clause SQL, so Flowable treats it as a caller mistake. At least one task ID must be supplied, or the call should be skipped.

Solutions

  1. Skip the call when the list is empty: only invoke taskIds if !ids.isEmpty().
  2. Populate the collection with the target task IDs before building the query.
  3. Short-circuit the whole query when no IDs remain, since the result set would be empty anyway.

Example fix

// before
query.taskIds(pendingIds); // empty
// after
if (!pendingIds.isEmpty()) {
    query.taskIds(pendingIds);
} else {
    return Collections.emptyList();
}
Defensive patterns

Strategy: validation

Validate before calling

if (taskIds != null && taskIds.isEmpty()) {
    // return empty result early or populate before querying
}

Type guard

boolean hasTaskIds(Collection<String> ids) {
    return ids != null && !ids.isEmpty();
}

Try / catch

try {
    query.taskIds(ids);
} catch (FlowableIllegalArgumentException e) {
    logger.warn("Empty task id list: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling historicTaskInstanceQuery().taskIds(new ArrayList<>()) or with a collection emptied by prior filtering/removal of processed IDs.

Common situations: All IDs consumed/filtered in a batch loop leaving an empty residual list; empty search results from a previous query reused as input; default-initialized collection never populated.

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/1840f386cdbaa956. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java:716

    }

    @Override
    public HistoricTaskInstanceQuery taskId(String taskId) {
        if (inOrStatement) {
            this.currentOrQueryObject.taskId = taskId;
        } else {
            this.taskId = taskId;
        }
        return this;
    }

    @Override
    public HistoricTaskInstanceQuery taskIds(Collection<String> taskIds) {
        if (taskIds == null) {
            throw new FlowableIllegalArgumentException("Task id list is null");
        }
        if (taskIds.isEmpty()) {
            throw new FlowableIllegalArgumentException("Task id list is empty");
        }
        if (inOrStatement) {
            this.currentOrQueryObject.taskIds = taskIds;
        } else {
            this.taskIds = taskIds;
        }
        return this;
    }

    @Override
    public HistoricTaskInstanceQuery taskName(String taskName) {
        if (inOrStatement) {
            this.currentOrQueryObject.taskName = taskName;
        } else {
            this.taskName = taskName;
        }
        return this;
    }

View on GitHub (pinned to d6d39ce1c6)