AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend): Make Jinja Error on TextFormatter as value error (#11236)
Zamil Majdybb0b45d7f7fd
diff --git a/autogpt_platform/backend/backend/util/text.py b/autogpt_platform/backend/backend/util/text.pyindex 45681aeaec..be80299ba7 100644--- a/autogpt_platform/backend/backend/util/text.py+++ b/autogpt_platform/backend/backend/util/text.py@@ -3,6 +3,7 @@ import loggingimport bleachfrom bleach.css_sanitizer import CSSSanitizerfrom jinja2 import BaseLoader+from jinja2.exceptions import TemplateErrorfrom jinja2.sandbox import SandboxedEnvironmentfrom markupsafe import Markup@@ -101,8 +102,11 @@ class TextFormatter:def format_string(self, template_str: str, values=None, **kwargs) -> str:"""Regular template rendering with escaping"""- template = self.env.from_string(template_str)- return template.render(values or {}, **kwargs)+ try:+ template = self.env.from_string(template_str)+ return template.render(values or {}, **kwargs)+ except TemplateError as e:+ raise ValueError(e) from edef format_email(self,