flowable/flowable-engine · error · FlowableIllegalArgumentException

caseInstanceId is null

Error message

caseInstanceId is null

What it means

Thrown by SetVariablesAsyncCmd.execute when caseInstanceId is null. The bulk async variable setter validates the case instance id before the null/emptiness checks on the variables map and rejects null ids with FlowableIllegalArgumentException.

Source

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

import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;

public class SetVariablesAsyncCmd extends AbstractSetVariableAsyncCmd implements Command<Void> {
    
    protected String caseInstanceId;
    protected Map<String, Object> variables;
    
    public SetVariablesAsyncCmd(String caseInstanceId, Map<String, Object> variables) {
        this.caseInstanceId = caseInstanceId;
        this.variables = variables;
    }
    
    @Override
    public Void execute(CommandContext commandContext) {
        if (caseInstanceId == null) {
            throw new FlowableIllegalArgumentException("caseInstanceId is null");
        }
        if (variables == null) {
            throw new FlowableIllegalArgumentException("variables is null");
        }
        if (variables.isEmpty()) {
            throw new FlowableIllegalArgumentException("variables is empty");
        }
     
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);
        if (caseInstanceEntity == null) {
            throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class);
        }
        
        for (String variableName : variables.keySet()) {
            addVariable(false, caseInstanceId, null, variableName, variables.get(variableName), caseInstanceEntity.getTenantId(), 
                    cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService());
        }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Ensure caseInstanceId is set before calling setVariablesAsync
  2. Validate the id non-null/non-empty at the boundary of your service
  3. Fix the producer of the id that returned null

Example fix

// before
cmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);
// after
Objects.requireNonNull(caseInstanceId, "caseInstanceId required");
cmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);
Defensive patterns

Strategy: validation

Validate before calling

if (caseInstanceId == null || caseInstanceId.trim().isEmpty()) {
    throw new IllegalArgumentException("caseInstanceId must not be null or empty");
}

Type guard

boolean hasCaseInstanceId(String id) { return id != null && !id.trim().isEmpty(); }

Try / catch

try {
    cmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);
} catch (FlowableIllegalArgumentException e) {
    log.error("Invalid argument for setVariablesAsync: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling setVariablesAsync with a null id, or constructing SetVariablesAsyncCmd without initializing caseInstanceId.

Common situations: Id lost between service layers, earlier query returned null unchecked, REST payload omitted the id field.

Related errors


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