flowable/flowable-engine · error · ActivitiIllegalArgumentException
Cannot use taskIds together with excludeTaskVariables
Error message
Cannot use taskIds together with excludeTaskVariables
What it means
Like taskId(), taskIds() conflicts with a previously set excludeTaskRelated flag: filtering by a set of tasks and excluding task-related variables cannot both apply. The engine throws ActivitiIllegalArgumentException when taskIds() is called after excludeTaskVariables().
Solutions
- Drop excludeTaskVariables() if you mean to filter by the given task ID set.
- Reorder or conditionally apply filters so both options never coexist.
- Use separate query objects for the 'exclude' and 'by-task-ids' cases.
Example fix
// before query.excludeTaskVariables().taskIds(ids); // after query.taskIds(ids); // choose one mode, not both
Defensive patterns
Strategy: validation
Validate before calling
boolean excludeTask = cfg.getBoolean("excludeTaskVariables", false);
if (excludeTask) {
query.excludeTaskVariables();
} else if (taskIds != null && !taskIds.isEmpty()) {
query.taskIds(taskIds);
} Try / catch
try { query.taskIds(ids); } catch (org.activiti.engine.ActivitiIllegalArgumentException e) { throw new IllegalStateException("taskIds cannot be combined with excludeTaskVariables", e); } Prevention
- Reject conflicting filter flags in request DTO validation before building the query.
- Model the two modes as an enum in your API instead of independent booleans.
- Write integration tests covering the flag combinations you allow.
When it happens
Trigger: historyService.createHistoricVariableInstanceQuery().excludeTaskVariables().taskIds(set) throws immediately.
Common situations: Dynamic query builders appending filters from a config/params map in fixed order, hitting the conflict whenever 'excludeTaskVariables' precedes 'taskIds'; shared/reused query instances.
Related errors
- Cannot use taskId together with excludeTaskVariables
- Business key is null
- Execution id is null
- id is null
- ids are null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/cf797468cbd8a7a8.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricVariableInstanceQueryImpl.java:124
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");
}
excludeTaskRelated = true;
return this;
}
@OverrideView on GitHub (pinned to d6d39ce1c6)