flowable/flowable-engine · error · ActivitiIllegalArgumentException

processInstanceId is null

Error message

processInstanceId is null

What it means

SetProcessInstanceNameCmd.execute() performs its own null check and throws ActivitiIllegalArgumentException with the literal message 'processInstanceId is null' when the constructor was given a null id (this command, unlike the others, permits constructing it with null and fails only at execution time).

Solutions

  1. Guard the id before calling: only invoke setProcessInstanceName when the id is non-null.
  2. Resolve the id via createProcessInstanceQuery().singleResult() and check for null first.
  3. Note the difference from sibling commands: this one validates in execute(), so also wrap execution in try-catch for ActivitiIllegalArgumentException.

Example fix

// before
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(bk).singleResult();
managementService.setProcessInstanceName(pi.getId(), name); // pi may be null
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(bk).singleResult();
if (pi != null) {
    managementService.setProcessInstanceName(pi.getId(), name);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (pi == null || pi.getId() == null) {
    throw new IllegalStateException("No running instance to rename");
}

Type guard

boolean canRename(ProcessInstance pi) { return pi != null && pi.getId() != null; }

Try / catch

try {
    managementService.setProcessInstanceName(pid, name);
} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {
    if ("processInstanceId is null".equals(e.getMessage())) {
        // id was never provided; fix upstream lookup
    }
}

Prevention

When it happens

Trigger: managementService.setProcessInstanceName(null, name) or new SetProcessInstanceNameCmd(null, name).execute(...) — the id field was null because it came from an unpopulated bean, optional, or map lookup.

Common situations: Chained calls where an earlier query returned null (singleResult() on a miss) and its id was passed on; reflection-driven invocation with missing parameters.

Related errors


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

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/SetProcessInstanceNameCmd.java:40

import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.runtime.ProcessInstance;

public class SetProcessInstanceNameCmd implements Command<Void>, Serializable {

    private static final long serialVersionUID = 1L;

    protected String processInstanceId;
    protected String name;

    public SetProcessInstanceNameCmd(String processInstanceId, String name) {
        this.processInstanceId = processInstanceId;
        this.name = name;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (processInstanceId == null) {
            throw new ActivitiIllegalArgumentException("processInstanceId is null");
        }

        ExecutionEntity execution = commandContext
                .getExecutionEntityManager()
                .findExecutionById(processInstanceId);

        if (execution == null) {
            throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
        }

        if (!execution.isProcessInstanceType()) {
            throw new ActivitiObjectNotFoundException("process instance " + processInstanceId +
                    " doesn't exist, the given ID references an execution, though", ProcessInstance.class);
        }

        if (execution.isSuspended()) {
            throw new ActivitiException("process instance " + processInstanceId + " is suspended, cannot set name");
        }

View on GitHub (pinned to d6d39ce1c6)