flowable/flowable-engine · error · FlowableIllegalArgumentException

taskId is required

Error message

taskId is required

What it means

GetHistoricEntityLinkParentsForTaskCmd returns the historic entity link parents of a task. Its constructor throws FlowableIllegalArgumentException when taskId is null, consistent with Flowable's constructor-level null checks for command objects.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetHistoricEntityLinkParentsForTaskCmd.java:34

import java.util.List;

import org.flowable.cmmn.engine.CmmnEngineConfiguration;
import org.flowable.cmmn.engine.impl.util.CommandContextUtil;
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.api.scope.ScopeTypes;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.entitylink.api.EntityLinkType;
import org.flowable.entitylink.api.history.HistoricEntityLink;

public class GetHistoricEntityLinkParentsForTaskCmd implements Command<List<HistoricEntityLink>>, Serializable {

    private static final long serialVersionUID = 1L;
    protected String taskId;

    public GetHistoricEntityLinkParentsForTaskCmd(String taskId) {
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId is required");
        }
        this.taskId = taskId;
    }

    @Override
    public List<HistoricEntityLink> execute(CommandContext commandContext) {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        return cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService()
                .findHistoricEntityLinksByReferenceScopeIdAndType(taskId, ScopeTypes.TASK, EntityLinkType.CHILD);
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Pass a non-null taskId to the command.
  2. Capture DelegateTask.getId() inside task-scoped listeners instead of a nullable field.
  3. Validate the id before invoking the history service.

Example fix

// before
new GetHistoricEntityLinkParentsForTaskCmd(taskInfo.getId());
// after
String taskId = taskInfo != null ? taskInfo.getId() : null;
Objects.requireNonNull(taskId, "taskId must be provided");
new GetHistoricEntityLinkParentsForTaskCmd(taskId);
Defensive patterns

Strategy: validation

Validate before calling

if (taskId == null) { throw new IllegalArgumentException("taskId must be provided"); }

Type guard

boolean hasTaskId = t != null && t.getId() != null;

Try / catch

try { ... } catch (FlowableIllegalArgumentException e) { throw new BadRequestException("taskId is required"); }

Prevention

When it happens

Trigger: Constructing the command with a null taskId, typically when the id is read from a nullable source (DelegateTask absent, missing path variable, null map value).

Common situations: Listeners/delegates running outside task scope, wrong variable used for the id, REST layer dropping the task id.

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/9bd7b78d862ad71b. Report an issue: GitHub.