{"record":{"id":"68d2f932c49b5637","repo":"flowable/flowable-engine","slug":"could-not-find-plan-item-instance-for-68d2f9","errorCode":null,"errorMessage":"Could not find plan item instance for ","messagePattern":"Could not find plan item instance for ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"critical","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskWithFormCmd.java","lineNumber":182,"sourceCode":"        return null;\n    }\n\n    protected boolean isFormFieldValidationEnabled(TaskEntity task) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration();\n        if (cmmnEngineConfiguration.isFormFieldValidationEnabled() && CaseDefinitionUtil.getCmmnModel(task.getScopeDefinitionId()).\n                findPlanItemDefinition(task.getTaskDefinitionKey()) instanceof HasValidateFormFields hasValidateFormFields) {\n            String formFieldValidationExpression = hasValidateFormFields.getValidateFormFields();\n            return TaskHelper.isFormFieldValidationEnabled(task, cmmnEngineConfiguration, formFieldValidationExpression);\n        }\n        return false;\n    }\n\n    protected void completeTask(CommandContext commandContext, TaskEntity task, Map<String, Object> taskVariables) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        String planItemInstanceId = task.getSubScopeId();\n        PlanItemInstanceEntity planItemInstanceEntity = cmmnEngineConfiguration.getPlanItemInstanceEntityManager().findById(planItemInstanceId);\n        if (planItemInstanceEntity == null) {\n            throw new FlowableException(\"Could not find plan item instance for \" + task);\n        }\n\n        if (taskVariables != null) {\n            if (localScope) { // backwards compatibility from before variableLocal was available in constructor\n                task.setVariablesLocal(taskVariables);\n            } else {\n                task.setVariables(taskVariables);\n            }\n        }\n\n        if (variablesLocal != null) {\n            task.setVariablesLocal(variablesLocal);\n        }\n\n        if (transientVariables != null) {\n            if (localScope) { // backwards compatibility from before variableLocal was available in constructor\n                task.setTransientVariablesLocal(transientVariables);\n            } else {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskWithFormCmd.java#L164-L200","documentation":"Thrown by CompleteTaskWithFormCmd.completeTask when the task's subScopeId does not resolve to an existing plan item instance. Identical root cause as CompleteTaskCmd's variant: the CMMN plan item backing the task is gone (case terminated/deleted concurrently or data manipulated outside the engine), so form-based completion cannot continue.","triggerScenarios":"Calling completeTaskWithForm on a case task whose planItemInstanceEntityManager.findById(subScopeId) returns null after concurrent case termination, external table cleanup, or inconsistent backups.","commonSituations":"Task inbox race conditions with case termination; manual SQL maintenance on ACT_CMMN_RU_PLAN_ITEM_INST; partially restored databases.","solutions":["Confirm the case instance is still active and the plan item instance exists before completing the task with a form.","Never delete CMMN runtime rows manually; terminate cases via the engine API.","Handle the resulting FlowableException in the UI (task no longer completable) and refresh the task list."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    cmmnTaskService.completeTaskWithForm(taskId, formId, outcome, vars);\n} catch (FlowableException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Could not find plan item instance\")) {\n        log.warn(\"Underlying plan item gone for task {}\", taskId);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Avoid manual database edits of CMMN runtime tables.","Handle concurrent case termination in the UI by refreshing task state before form submission."],"tags":["cmmn","data-consistency","plan-item-instance","flowable"],"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"}