{"record":{"id":"2c37d6add8b2b6c8","repo":"kestra-io/kestra","slug":"trigger-variable-is-missing-executionid-key-not","errorCode":null,"errorMessage":"Trigger variable is missing 'executionId' key, notification plugins can only be used either on the current execution or an execution triggered by a Flow trigger.","messagePattern":"Trigger variable is missing 'executionId' key, notification plugins can only be used either on the current execution or an execution triggered by a Flow trigger\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/plugins/notifications/ExecutionService.java","lineNumber":57,"sourceCode":"            .ifPresent(s -> templateRenderMap.put(\"customMessage\", s));\n\n        final Map<String, Object> renderedCustomFields = runContext.render(executionInterface.getCustomFields()).asMap(String.class, Object.class);\n        if (!renderedCustomFields.isEmpty()) {\n            templateRenderMap.put(\"customFields\", renderedCustomFields);\n        }\n\n        templateRenderMap.put(\"firstFailed\", executionContext.firstFailed() != null ? executionContext.firstFailed() : false);\n        templateRenderMap.put(\"lastTask\", executionContext.lastTask());\n\n        return templateRenderMap;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static ExecutionContext contextFromTriggerExecution(RunContext runContext) {\n        Map<String, Object> executionMap = (Map<String, Object>) runContext.getVariables().get(\"execution\");\n        Map<String, Object> triggerVar = (Map<String, Object>) runContext.getVariables().get(\"trigger\");\n        if (triggerVar == null || !triggerVar.containsKey(\"executionId\")) {\n            throw new IllegalArgumentException(\n                \"Trigger variable is missing 'executionId' key, notification plugins can only be used either on the current execution or an execution triggered by a Flow trigger.\"\n            );\n        }\n\n        return new ExecutionContext(\n            (String) executionMap.get(\"tenantId\"),\n            (String) triggerVar.get(\"namespace\"),\n            (String) triggerVar.get(\"flowId\"),\n            (String) triggerVar.get(\"executionId\"),\n            new ExecutionContextState(\n                (String) triggerVar.get(\"state\"),\n                (String) triggerVar.get(\"startDate\"),\n                (String) triggerVar.get(\"endDate\")\n            ),\n            triggerVar.containsKey(\"firstFailedTaskId\") ? new ExecutionContextTask((String) triggerVar.get(\"firstFailedTaskId\")) : null,\n            triggerVar.containsKey(\"lastTaskId\") ? new ExecutionContextTask((String) triggerVar.get(\"lastTaskId\")) : null\n        );\n    }","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/plugins/notifications/ExecutionService.java#L39-L75","documentation":"Error \"Trigger variable is missing 'executionId' key, notification plugins can only be used either on the current execution or an execution triggered by a Flow trigger.\" thrown in kestra-io/kestra.","triggerScenarios":"Thrown at core/src/main/java/io/kestra/core/plugins/notifications/ExecutionService.java:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the notification plugin within a flow execution context, or on an execution started by a Flow trigger, so 'executionId' is present in the trigger variables.","If you must notify outside an execution, pass an explicit executionId to the notification task."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}