flowable/flowable-engine · error · ActivitiIllegalArgumentException
taskId or processInstanceId is required
Error message
taskId or processInstanceId is required
What it means
GetHistoricIdentityLinksForTaskCmd needs at least one of taskId or processInstanceId to query historic identity links. The constructor throws ActivitiIllegalArgumentException when both are null, since the query would have no filter at all.
Source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java:39
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.activiti.engine.task.IdentityLinkType;
/**
* @author Frederik Heremans
*/
public class GetHistoricIdentityLinksForTaskCmd implements Command<List<HistoricIdentityLink>>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
protected String processInstanceId;
public GetHistoricIdentityLinksForTaskCmd(String taskId, String processInstanceId) {
if (taskId == null && processInstanceId == null) {
throw new ActivitiIllegalArgumentException("taskId or processInstanceId is required");
}
this.taskId = taskId;
this.processInstanceId = processInstanceId;
}
@Override
public List<HistoricIdentityLink> execute(CommandContext commandContext) {
if (taskId != null) {
return getLinksForTask(commandContext);
} else {
return getLinksForProcessInstance(commandContext);
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<HistoricIdentityLink> getLinksForTask(CommandContext commandContext) {
HistoricTaskInstanceEntity task = commandContext
.getHistoricTaskInstanceEntityManager()View on GitHub (pinned to d6d39ce1c6)
Solutions
- Ensure at least one of taskId or processInstanceId is non-null before the call
- Add caller-side validation that rejects requests missing both parameters
- If querying by process instance, pass the processInstanceId instead of the (null) taskId
Example fix
// before
historyService.createHistoricTaskInstanceQuery(); // both ids null downstream
new GetHistoricIdentityLinksForTaskCmd(taskId, processInstanceId); // both null
// after
if (taskId == null && processInstanceId == null) {
throw new IllegalArgumentException("provide taskId or processInstanceId");
}
new GetHistoricIdentityLinksForTaskCmd(taskId, processInstanceId); Defensive patterns
Strategy: validation
Validate before calling
if (taskId == null && processInstanceId == null) {
throw new IllegalArgumentException("either taskId or processInstanceId must be provided");
} Type guard
boolean hasQueryTarget(String taskId, String processInstanceId) { return taskId != null || processInstanceId != null; } Try / catch
try {
new GetHistoricIdentityLinksForTaskCmd(taskId, processInstanceId).execute(ctx);
} catch (ActivitiIllegalArgumentException e) {
// reject request: no query target supplied
} Prevention
- Enforce XOR/at-least-one semantics in your API layer before reaching the engine
- Default to processInstanceId when task-scoped queries are not applicable
- Write integration tests covering both-null input
When it happens
Trigger: Calling HistoryService.getHistoricTaskIdentityLinks... style APIs / constructing GetHistoricIdentityLinksForTaskCmd(null, null) directly; typically happens when both caller-supplied ids were null.
Common situations: Passing through optional request parameters where neither taskId nor processInstanceId was provided; code paths that assume one of the two was set earlier.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- The process definition id is mandatory, but '' has been prov
- No historic task exists with the given id:
- baseUrl can not be null
- Could not find an app definition with id '<appDefinitionId>'
- Invalid action: '<action>'.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/3d965f295992b7cb.
Report an issue: GitHub.