From 257ef7e13bfb4bd6e11869ef30bd2bc9a04f6f2b Mon Sep 17 00:00:00 2001 From: Nikita Reznikov Date: Fri, 31 May 2024 22:29:15 +0300 Subject: [PATCH] Fix bug when trying to set undefined value in state in jinja event plugin --- eventum_plugins/event/jinja.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eventum_plugins/event/jinja.py b/eventum_plugins/event/jinja.py index b2aec04..3dd5c20 100644 --- a/eventum_plugins/event/jinja.py +++ b/eventum_plugins/event/jinja.py @@ -12,7 +12,7 @@ load_csv_sample) from jinja2 import (BaseLoader, Environment, FileSystemLoader, Template, TemplateError, TemplateNotFound, TemplateRuntimeError, - TemplateSyntaxError) + TemplateSyntaxError, Undefined) from pydantic import Field, field_validator from eventum_plugins.event.base import (BaseEventPlugin, EventPluginBaseConfig, @@ -126,6 +126,9 @@ def __init__(self) -> None: def set(self, key: str, value: Any) -> None: """Set variable value to state.""" + if isinstance(value, Undefined): + value = None + self._state[key] = value def get(self, key: str, default: Any | None = None) -> Any: