{"record":{"id":"67f183e2ed94b19c","repo":"flowable/flowable-engine","slug":"plan-item-instance-for-eventsubscription-can-not-67f183","errorCode":null,"errorMessage":"Plan item instance for {eventSubscription} can not be found with sub scope id {subScopeId}","messagePattern":"Plan item instance for (.+?) can not be found with sub scope id (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/impl/cmmn/DefaultCaseInstanceService.java","lineNumber":103,"sourceCode":"        }\n\n        CaseInstance caseInstance = caseInstanceBuilder.start();\n        return caseInstance.getId();\n    }\n\n    @Override\n    public void handleSignalEvent(EventSubscriptionEntity eventSubscription, Map<String, Object> variables) {\n        if (StringUtils.isEmpty(eventSubscription.getSubScopeId())) {\n            throw new FlowableException(\"Plan item instance for \" + eventSubscription + \" can not be found with empty sub scope id value\");\n        }\n        \n        CmmnRuntimeService cmmnRuntimeService = cmmnEngineConfiguration.getCmmnRuntimeService();\n        PlanItemInstance planItemInstance = cmmnRuntimeService.createPlanItemInstanceQuery()\n                        .planItemInstanceId(eventSubscription.getSubScopeId())\n                        .singleResult();\n        \n        if (planItemInstance == null) {\n            throw new FlowableException(\"Plan item instance for \" + eventSubscription + \" can not be found with sub scope id \" + eventSubscription.getSubScopeId());\n        }\n\n        cmmnRuntimeService.createPlanItemInstanceTransitionBuilder(planItemInstance.getId())\n            .variables(variables)\n            .trigger();\n    }\n\n    @Override\n    public void deleteCaseInstance(String caseInstanceId) {\n        cmmnEngineConfiguration.getCommandExecutor().execute(commandContext -> {\n            CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);\n            if (caseInstanceEntity == null || caseInstanceEntity.isDeleted() || CaseInstanceState.isInTerminalState(caseInstanceEntity)) {\n                return null;\n            }\n\n            CommandContextUtil.getAgenda(commandContext).planManualTerminateCaseInstanceOperation(caseInstanceEntity.getId());\n            return null;\n        });","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/impl/cmmn/DefaultCaseInstanceService.java#L85-L121","documentation":"Thrown by DefaultCaseInstanceService.handleSignalEvent when a CMMN event subscription points to a sub scope id for which no plan item instance exists in the runtime data. The engine cannot deliver the signal/trigger to a plan item that has disappeared, so it fails fast with FlowableException instead of silently dropping the event.","triggerScenarios":"A signal event handler resolves an EventSubscriptionEntity whose subScopeId no longer matches a live plan item instance (planItemInstanceQuery().planItemInstanceId(subScopeId).singleResult() returns null), typically because the plan item (stage/task) was completed, terminated, or the case instance ended before the signal was handled.","commonSituations":"Asynchronous signal delivery racing with case completion; signals fired after a plan item was exited by an exit criterion; stale event subscriptions left over from terminated stages; calling CmmnRuntimeService signal APIs for an already-finished case.","solutions":["Check that the case instance / plan item still exists (createPlanItemInstanceQuery) before sending the signal, and skip if absent","Review case model exit/sentry criteria so plan items are not terminated while signals are in flight","Reduce async boundaries or ensure the signal and the terminating transition are not racing (serialize via same transaction/async executor config)","Catch FlowableException around the signal call and treat 'already completed' as a benign outcome"],"exampleFix":"// before\ncmmnRuntimeService.signalEventReceived(signalName, executionId);\n\n// after\nPlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .planItemInstanceId(subScopeId).singleResult();\nif (pii != null) {\n    cmmnRuntimeService.createPlanItemInstanceTransitionBuilder(pii.getId()).trigger();\n}","handlingStrategy":"try-catch","validationCode":"PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .planItemInstanceId(subScopeId).singleResult();\nif (pii == null) { /* already completed/terminated: skip signal */ }","typeGuard":null,"tryCatchPattern":"try {\n    cmmnRuntimeService.createPlanItemInstanceTransitionBuilder(planItemId).trigger();\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"can not be found with sub scope id\")) {\n        // plan item already gone; treat as benign\n    } else { throw e; }\n}","preventionTips":["Query the plan item instance before triggering","Avoid long-lived pending signals that can outlive the plan item","Design sentries/exit criteria so terminating transitions cannot race signal delivery","Monitor for cases completing while signals are queued"],"tags":["cmmn","event-subscription","runtime","plan-item"],"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-14T05:17:10.506Z"}