{"record":{"id":"9625678074d68de8","repo":"flowable/flowable-engine","slug":"the-is-created-by-the-cmmn-engine-and-should-be-c-962567","errorCode":null,"errorMessage":"The  is created by the cmmn engine and should be completed via the cmmn engine API","messagePattern":"The  is created by the cmmn engine and should be completed via the cmmn engine API","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/CompleteTaskWithFormCmd.java","lineNumber":110,"sourceCode":"            Object> variables, Map<String, Object> variablesLocal, Map<String, Object> transientVariables, Map<String, Object> transientVariablesLocal) {\n        this(taskId, formDefinitionId, outcome, variables);\n        this.variablesLocal = variablesLocal;\n        this.transientVariables = transientVariables;\n        this.transientVariablesLocal = transientVariablesLocal;\n    }\n    \n    public CompleteTaskWithFormCmd(String taskId, String formDefinitionId, String outcome, String userId, \n            Map<String, Object> variables, Map<String, Object> variablesLocal, \n            Map<String, Object> transientVariables, Map<String, Object> transientVariablesLocal) {\n        \n        this(taskId, formDefinitionId, outcome, variables, variablesLocal, transientVariables, transientVariablesLocal);\n        this.userId = userId;\n    }\n\n    @Override\n    protected Void execute(CommandContext commandContext, TaskEntity task) {\n        if (StringUtils.isNotEmpty(task.getScopeId()) && ScopeTypes.CMMN.equals(task.getScopeType())) {\n            throw new FlowableException(\"The \" + task + \" is created by the cmmn engine and should be completed via the cmmn engine API\");\n        }\n        \n        FormService formService = CommandContextUtil.getFormService();\n        if (formService == null) {\n            throw new FlowableIllegalArgumentException(\"Form engine is not initialized\");\n        }\n\n        FormRepositoryService formRepositoryService = CommandContextUtil.getFormRepositoryService();\n        FormInfo formInfo = formRepositoryService.getFormModelById(formDefinitionId);\n\n        Map<String, Object> formVariables;\n        boolean local = variablesLocal != null && !variablesLocal.isEmpty();\n        if (local) {\n            formVariables = variablesLocal;\n        } else {\n            formVariables = variables;\n        }\n        Map<String, Object> taskVariables = null;","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/CompleteTaskWithFormCmd.java#L92-L128","documentation":"CompleteTaskWithFormCmd refuses to complete a task that was created by the CMMN engine. Such tasks are owned and lifecycle-managed by the CMMN engine, so completing them through the process (BPMN) task-form API would bypass CMMN state management. The library throws a plain FlowableException to force callers onto the correct engine API.","triggerScenarios":"Calling TaskService.completeTaskWithForm (or the CompleteTaskWithFormCmd command directly) on a TaskEntity whose scopeId is set and whose scopeType equals ScopeTypes.CMMN, i.e. a task originating from a CMMN case rather than a BPMN process.","commonSituations":"Applications that mix BPMN processes and CMMN cases and use a generic 'complete task with form' endpoint keyed only by taskId; after migration to Flowable 6 where CMMN-managed tasks appear in the same task queries as BPMN tasks; UI task lists that do not distinguish task scope.","solutions":["Check task.getScopeType() before completing; if it is 'cmmn', call the CMMN engine API instead: CmmnTaskService.completeTaskWithForm(taskId, formDefinitionId, formOutcome, variables).","Inspect the task (taskService.createTaskQuery().taskId(id).singleResult()) to see scopeType/scopeId and route to the proper service programmatically.","If the task should not be a CMMN task, fix the deployment: it was started from a case definition, not a process definition."],"exampleFix":"// before\ntaskService.completeTaskWithForm(taskId, formId, outcome, vars);\n// after\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (ScopeTypes.CMMN.equals(task.getScopeType())) {\n    cmmnTaskService.completeTaskWithForm(taskId, formId, outcome, vars);\n} else {\n    taskService.completeTaskWithForm(taskId, formId, outcome, vars);\n}","handlingStrategy":"type-guard","validationCode":"Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\nboolean isCmmnTask = t != null && \"cmmn\".equals(t.getScopeType());\nif (isCmmnTask) { /* route to cmmnTaskService.completeTaskWithForm(...) */ }","typeGuard":"boolean isCmmnTask(Task t) { return t != null && ScopeTypes.CMMN.equals(t.getScopeType()); }","tryCatchPattern":"try {\n    taskService.completeTaskWithForm(taskId, formId, outcome, vars);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"cmmn engine\")) {\n        cmmnTaskService.completeTaskWithForm(taskId, formId, outcome, vars);\n    } else { throw e; }\n}","preventionTips":["Centralize task completion in one service that checks scopeType before dispatching to BPMN or CMMN API","Never call BPMN task-form APIs from case-related screens","Store scopeType alongside task ids in UI state"],"tags":["flowable","cmmn","task-api-misuse"],"backgroundTag":"unsupported-operation","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"}