flowable/flowable-engine · error · ActivitiIllegalArgumentException
taskIds is null
Error message
taskIds is null
What it means
HistoricVariableInstanceQueryImpl.taskIds(Set<String>) validates its argument before use and throws ActivitiIllegalArgumentException when the passed set is null. A null set carries no task filter information, so the query would silently be wrong; the library fails fast instead. Pass a non-null, non-empty set of task IDs.
Solutions
- Ensure the set is initialized (e.g. new HashSet<>()) before calling taskIds().
- Guard the call: only invoke taskIds() when the set is non-null; skip the filter otherwise.
- Fix the upstream source that produced null instead of an empty collection.
Example fix
// before
query.taskIds(taskIds);
// after
if (taskIds != null && !taskIds.isEmpty()) {
query.taskIds(taskIds);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (taskIds == null) { taskIds = java.util.Collections.emptySet(); }
if (!taskIds.isEmpty()) { query.taskIds(taskIds); } Type guard
boolean hasTaskIds(Set<String> s) { return s != null && !s.isEmpty(); } Try / catch
try { query.taskIds(taskIds); } catch (org.activiti.engine.ActivitiIllegalArgumentException e) { throw new IllegalArgumentException("taskIds set must be non-null and non-empty", e); } Prevention
- Initialize ID collections eagerly (new HashSet<>()) rather than leaving them null.
- Prefer returning empty collections over null from DAOs (Collections.emptySet()).
- Validate inputs at the API boundary before building queries.
When it happens
Trigger: historyService.createHistoricVariableInstanceQuery().taskIds(null) — e.g. when a collection that was expected to hold task IDs is null (uninitialized variable, failed lookup, absent method parameter).
Common situations: Passing an optional task ID list straight into taskIds() without a null check; a repository/DAO returning null instead of an empty collection; NPE-avoidance refactor replacing direct dereference with this setter that then rejects null.
Related errors
- Business key is null
- Execution id is null
- Parent id is null
- Process definition keys is null
- Process definition version is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/c1b0daef5e3c273e.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricVariableInstanceQueryImpl.java:118
return this;
}
@Override
public HistoricVariableInstanceQuery taskId(String taskId) {
if (taskId == null) {
throw new ActivitiIllegalArgumentException("taskId is null");
}
if (excludeTaskRelated) {
throw new ActivitiIllegalArgumentException("Cannot use taskId together with excludeTaskVariables");
}
this.taskId = taskId;
return this;
}
@Override
public HistoricVariableInstanceQueryImpl taskIds(Set<String> taskIds) {
if (taskIds == null) {
throw new ActivitiIllegalArgumentException("taskIds is null");
}
if (taskIds.isEmpty()) {
throw new ActivitiIllegalArgumentException("Set of taskIds is empty");
}
if (excludeTaskRelated) {
throw new ActivitiIllegalArgumentException("Cannot use taskIds together with excludeTaskVariables");
}
this.taskIds = taskIds;
return this;
}
@Override
public HistoricVariableInstanceQuery excludeTaskVariables() {
if (taskId != null) {
throw new ActivitiIllegalArgumentException("Cannot use taskId together with excludeTaskVariables");
}
if (taskIds != null) {
throw new ActivitiIllegalArgumentException("Cannot use taskIds together with excludeTaskVariables");View on GitHub (pinned to d6d39ce1c6)