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

  1. Ensure at least one of taskId or processInstanceId is non-null before the call
  2. Add caller-side validation that rejects requests missing both parameters
  3. 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

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/3d965f295992b7cb. Report an issue: GitHub.