flowable/flowable-engine · error · FlowableIllegalArgumentException
taskId is null
Error message
taskId is null
What it means
VariableInstanceQuery.taskId(String) requires a non-null task id. Passing null throws FlowableIllegalArgumentException immediately because filtering variables by an absent task is invalid. This is a query-build-time validation; no query executes.
Solutions
- Validate the task id is non-null before building the query
- Only call taskId() when a task id is actually available; use a different filter otherwise
- Ensure the id source (e.g. DelegateTask.getId()) is used in a task-scoped context
Example fix
// before
query.taskId(taskId); // may be null
// after
if (taskId != null) {
query.taskId(taskId);
} Defensive patterns
Strategy: validation
Validate before calling
if (taskId == null) {
throw new IllegalArgumentException("taskId is required");
} Type guard
boolean hasTaskId(String taskId) { return taskId != null && !taskId.isBlank(); } Try / catch
try {
query.taskId(taskId);
} catch (FlowableIllegalArgumentException e) {
if (e.getMessage().equals("taskId is null")) {
// skip or use alternative query
} else { throw e; }
} Prevention
- Verify the execution context actually provides a task id (user tasks only)
- Null-check ids from map lookups and delegates before querying
- Document that taskId() must come from a task-scoped context
When it happens
Trigger: Passing a null taskId, typically from an uninitialized variable, a map lookup that missed, or a service method forwarding an optional task id as null.
Common situations: Task id looked up from an execution/process context where the current scope is not task-based (e.g. a service task, not a user task), yielding null.
Related errors
- executionIds is null
- taskIds is null
- Cannot use executionId together with excludeLocalVariables
- Cannot use executionIds together with excludeLocalVariables
- Cannot use taskId together with excludeTaskVariables
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/679010c95ea16fbe.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java:121
if (executionIds.isEmpty()) {
throw new FlowableIllegalArgumentException("Set of executionIds is empty");
}
if (excludeLocalVariables) {
throw new FlowableIllegalArgumentException("Cannot use executionIds together with excludeLocalVariables");
}
this.executionIds = executionIds;
return this;
}
public VariableInstanceQuery activityInstanceId(String activityInstanceId) {
this.activityInstanceId = activityInstanceId;
return this;
}
@Override
public VariableInstanceQuery taskId(String taskId) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("taskId is null");
}
if (excludeTaskRelated) {
throw new FlowableIllegalArgumentException("Cannot use taskId together with excludeTaskVariables");
}
if (excludeLocalVariables) {
throw new FlowableIllegalArgumentException("Cannot use taskIds together with excludeLocalVariables");
}
this.taskId = taskId;
return this;
}
@Override
public VariableInstanceQueryImpl taskIds(Set<String> taskIds) {
if (taskIds == null) {
throw new FlowableIllegalArgumentException("taskIds is null");
}
if (taskIds.isEmpty()) {
throw new FlowableIllegalArgumentException("Set of taskIds is empty");View on GitHub (pinned to d6d39ce1c6)