{"record":{"id":"993918fc08259d86","repo":"flowable/flowable-engine","slug":"no-task-entity-found-for","errorCode":null,"errorMessage":"No task entity found for ","messagePattern":"No task entity found for ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java","lineNumber":476,"sourceCode":"            Expression expression = expressionManager.createExpression(humanTask.getTaskIdVariableName());\n            String idVariableName = (String) expression.getValue(planItemInstanceEntity);\n            if (StringUtils.isNotEmpty(idVariableName)) {\n                planItemInstanceEntity.setVariable(idVariableName, taskEntity.getId());\n            }\n        }\n    }\n\n    @Override\n    public void trigger(CommandContext commandContext, PlanItemInstanceEntity planItemInstance) {\n        if (!PlanItemInstanceState.ACTIVE.equals(planItemInstance.getState())) {\n            throw new FlowableIllegalStateException(\"Can only trigger a human task plan item that is in the ACTIVE state\");\n        }\n\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        TaskService taskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService();\n        List<TaskEntity> taskEntities = taskService.findTasksBySubScopeIdScopeType(planItemInstance.getId(), ScopeTypes.CMMN);\n        if (taskEntities == null || taskEntities.isEmpty()) {\n            throw new FlowableException(\"No task entity found for \" + planItemInstance);\n        }\n\n        // Should be only one\n        for (TaskEntity taskEntity : taskEntities) {\n            if (!taskEntity.isDeleted()) {\n                TaskHelper.completeTask(taskEntity, taskEntity.getTempCompletedBy(), cmmnEngineConfiguration);\n            }\n        }\n\n        CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstance);\n    }\n\n    @Override\n    public void onStateTransition(CommandContext commandContext, DelegatePlanItemInstance planItemInstance, String transition) {\n        if (PlanItemTransition.TERMINATE.equals(transition) || PlanItemTransition.EXIT.equals(transition)) {\n            CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n            TaskService taskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService();\n            List<TaskEntity> taskEntities = taskService.findTasksBySubScopeIdScopeType(planItemInstance.getId(), ScopeTypes.CMMN);","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java#L458-L494","documentation":"After confirming the plan item is ACTIVE, trigger() looks up the underlying TaskEntity by the plan item's id as subScopeId. If no task rows are found — an internal consistency violation — Flowable throws FlowableException with the plan item instance's toString, because a task-backed human plan item must always have a corresponding task.","triggerScenarios":"trigger() on an ACTIVE human task plan item where findTasksBySubScopeIdScopeType(planItemInstance.getId(), CMMN) returns null or an empty list — e.g. the task was deleted directly via TaskService/outside the engine, data was manipulated in the DB, or task creation was skipped/failed earlier.","commonSituations":"Tasks deleted with taskService.deleteTask bypassing task completion logic; database cleanup/migration scripts removing ACT_RU_TASK rows; manually activating plan items whose task creation failed; restoring CMMN data from backups inconsistently.","solutions":["Never delete runtime tasks directly with taskService.deleteTask; complete them via TaskService.completeTask or let the CMMN engine handle exit/termination.","Verify ACT_RU_TASK rows for the plan item id (query: select * from ACT_RU_TASK where SUB_SCOPE_ID_ = '<planItemInstanceId>').","If data was corrupted, recreate or re-trigger the case via a new case instance rather than patching rows.","Catch FlowableException in trigger flows and log planItemInstance.getId() to investigate missing task data."],"exampleFix":"// before\ntaskService.deleteTask(taskId); // removes ACT_RU_TASK row, CMMN trigger later fails\n// after\ntaskService.completeTask(taskId);","handlingStrategy":"validation","validationCode":"List<Task> tasks = taskService.createTaskQuery()\n    .subScopeId(planItemInstanceId).list();\nif (tasks.isEmpty()) throw new IllegalStateException(\"No runtime task for plan item \" + planItemInstanceId + \"; data may be corrupted\");","typeGuard":"null","tryCatchPattern":"try {\n    runtimeService.triggerPlanItemInstance(id);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"No task entity found for\")) {\n        log.error(\"Missing ACT_RU_TASK row for plan item {} - check for direct task deletions\", id);\n    }\n}","preventionTips":["Never delete runtime tasks directly with taskService.deleteTask","Let the CMMN engine terminate/exit plan items so tasks are removed through TaskHelper","Audit DB maintenance/migration scripts that touch ACT_RU_TASK","Monitor for orphaned ACTIVE plan items without tasks"],"tags":["cmmn","task-entity","internal-invariant","data-consistency"],"backgroundTag":"entity-not-found","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"}