{"record":{"id":"2dd1afdf2d0f3c00","repo":"flowable/flowable-engine","slug":"compensating-execution-not-set-for-compensate-even","errorCode":null,"errorMessage":"Compensating execution not set for compensate event subscription with id ${eventSubscription.getId()}","messagePattern":"Compensating execution not set for compensate event subscription with id (.+?)","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/event/CompensationEventHandler.java","lineNumber":48,"sourceCode":"\r\n/**\r\n * @author Daniel Meyer\r\n */\r\npublic class CompensationEventHandler implements EventHandler {\r\n\r\n    public static final String EVENT_HANDLER_TYPE = \"compensate\";\r\n\r\n    @Override\r\n    public String getEventHandlerType() {\r\n        return EVENT_HANDLER_TYPE;\r\n    }\r\n\r\n    @Override\r\n    public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {\r\n\r\n        String configuration = eventSubscription.getConfiguration();\r\n        if (configuration == null) {\r\n            throw new ActivitiException(\"Compensating execution not set for compensate event subscription with id \" + eventSubscription.getId());\r\n        }\r\n\r\n        ExecutionEntity compensatingExecution = commandContext.getExecutionEntityManager()\r\n                .findExecutionById(configuration);\r\n\r\n        ActivityImpl compensationHandler = eventSubscription.getActivity();\r\n\r\n        if ((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null\r\n                || !(Boolean) compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION))\r\n                && compensationHandler.isScope()) {\r\n\r\n            // descend into scope:\r\n            List<CompensateEventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();\r\n            ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);\r\n\r\n        } else {\r\n            try {\r\n\r","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/event/CompensationEventHandler.java#L30-L66","documentation":"CompensationEventHandler handles compensation event subscriptions. The subscription's configuration must store the id of the compensating execution; if the configuration is null the handler throws ActivitiException because it cannot locate the execution that will run the compensation handler.","triggerScenarios":"handleEvent on a COMPENSATE EventSubscriptionEntity whose getConfiguration() returns null — corrupted or legacy subscription data missing the compensating execution reference.","commonSituations":"Engine version upgrades/migrations where compensation subscription configuration wasn't populated; manual database edits or data corruption; throwing compensation in a process whose subscription state is inconsistent.","solutions":["Verify the event subscription row's CONFIGURATION_ column contains a valid execution id; fix data if corrupted","Redeploy and restart the affected process instances rather than repairing subscriptions by hand","Check engine/migration scripts populated compensation subscription configuration for the version in use"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"EventSubscriptionEntity sub = /* load subscription */;\nif (sub.getConfiguration() == null) {\n    throw new IllegalStateException(\"Compensation subscription missing compensating execution id\");\n}","typeGuard":"boolean hasCompensatingExecution(EventSubscriptionEntity s) {\n    return s != null && s.getConfiguration() != null;\n}","tryCatchPattern":"try {\n    runtimeService.startProcessInstanceByKey(\"proc\"); // trigger compensation flow\n} catch (ActivitiException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Compensating execution not set\")) {\n        // subscription data corrupted; restart instance / fix data\n    }\n}","preventionTips":["Do not hand-edit ACT_RU_EVENT_SUBSCRIP rows; configuration is engine-managed","Run official upgrade/migration scripts when moving engine versions","Validate compensation modeling (throw/end compensation events) in integration tests"],"tags":["compensation","event-subscription","internal-state"],"backgroundTag":"internal-invariant-violation","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"}