{"record":{"id":"a28e9b46e37c7c48","repo":"flowable/flowable-engine","slug":"modelid-is-null-a28e9b","errorCode":null,"errorMessage":"modelId is null","messagePattern":"modelId is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetModelEditorSourceCmd.java","lineNumber":37,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.engine.impl.util.CommandContextUtil;\n\n/**\n * @author Tijs Rademakers\n */\npublic class GetModelEditorSourceCmd implements Command<byte[]>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String modelId;\n\n    public GetModelEditorSourceCmd(String modelId) {\n        this.modelId = modelId;\n    }\n\n    @Override\n    public byte[] execute(CommandContext commandContext) {\n        if (modelId == null) {\n            throw new FlowableIllegalArgumentException(\"modelId is null\");\n        }\n\n        byte[] bytes = CommandContextUtil.getModelEntityManager(commandContext).findEditorSourceByModelId(modelId);\n\n        return bytes;\n    }\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":46,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetModelEditorSourceCmd.java#L19-L46","documentation":"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.","triggerScenarios":"Calling RepositoryService.getModelEditorSource(null) — typically because the model lookup that produced the id earlier returned null/undefined and the null was passed straight through.","commonSituations":"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.","solutions":["Add a null check on the model id before calling the API and fail with a clear message","Resolve the model first and verify it exists: repositoryService.createModelQuery().modelId(id).singleResult()","If the id comes from a request parameter, validate it at the controller/REST layer","Trace why the variable holding the id was null (earlier query returned null singleResult)"],"exampleFix":"// before\nbyte[] source = repositoryService.getModelEditorSource(model.getId()); // model may be null\n// after\nif (model == null || model.getId() == null) {\n    throw new IllegalArgumentException(\"Model not found; cannot fetch editor source\");\n}\nbyte[] source = repositoryService.getModelEditorSource(model.getId());","handlingStrategy":"validation","validationCode":"if (modelId == null || modelId.isEmpty()) {\n  throw new IllegalArgumentException(\"modelId must be provided\");\n}","typeGuard":"boolean hasModelId(String id) { return id != null && !id.isEmpty(); }","tryCatchPattern":"try {\n  byte[] src = repositoryService.getModelEditorSource(modelId);\n} catch (FlowableIllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Callers must supply a model id\", e);\n}","preventionTips":["Null-check results of singleResult() before calling .getId()","Validate request parameters at the API boundary","Prefer resolving the model object and asserting non-null before use"],"tags":["flowable","null-argument","model","validation"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}