flowable/flowable-engine · error · FlowableIllegalArgumentException

modelId is null

Error message

modelId is null

What it means

GetModelEditorSourceCmd.execute validates its constructor argument and throws FlowableIllegalArgumentException('modelId is null') before touching the database. Getting a model's editor source bytes is meaningless without a model id, so the command fails fast. This is a caller programming error, not a data problem.

Solutions

  1. Add a null check on the model id before calling the API and fail with a clear message
  2. Resolve the model first and verify it exists: repositoryService.createModelQuery().modelId(id).singleResult()
  3. If the id comes from a request parameter, validate it at the controller/REST layer
  4. Trace why the variable holding the id was null (earlier query returned null singleResult)

Example fix

// before
byte[] source = repositoryService.getModelEditorSource(model.getId()); // model may be null
// after
if (model == null || model.getId() == null) {
    throw new IllegalArgumentException("Model not found; cannot fetch editor source");
}
byte[] source = repositoryService.getModelEditorSource(model.getId());
Defensive patterns

Strategy: validation

Validate before calling

if (modelId == null || modelId.isEmpty()) {
  throw new IllegalArgumentException("modelId must be provided");
}

Type guard

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

Try / catch

try {
  byte[] src = repositoryService.getModelEditorSource(modelId);
} catch (FlowableIllegalArgumentException e) {
  throw new IllegalArgumentException("Callers must supply a model id", e);
}

Prevention

When it happens

Trigger: Calling RepositoryService.getModelEditorSource(null) — typically because the model lookup that produced the id earlier returned null/undefined and the null was passed straight through.

Common situations: Chaining modelService.createModelQuery()...singleResult() which returns null for a missing model and then passing .getId(); JavaScript/REST clients sending no modelId path parameter; refactoring that dropped an id assignment.

Related errors


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

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetModelEditorSourceCmd.java:37

import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.util.CommandContextUtil;

/**
 * @author Tijs Rademakers
 */
public class GetModelEditorSourceCmd implements Command<byte[]>, Serializable {

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

    public GetModelEditorSourceCmd(String modelId) {
        this.modelId = modelId;
    }

    @Override
    public byte[] execute(CommandContext commandContext) {
        if (modelId == null) {
            throw new FlowableIllegalArgumentException("modelId is null");
        }

        byte[] bytes = CommandContextUtil.getModelEntityManager(commandContext).findEditorSourceByModelId(modelId);

        return bytes;
    }

}

View on GitHub (pinned to d6d39ce1c6)