You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/13 07:25:48 UTC

[GitHub] [airflow] uranusjr commented on pull request #22218: Do not use native obj Jinja2 env to render error emails

uranusjr commented on pull request #22218:
URL: https://github.com/apache/airflow/pull/22218#issuecomment-1066043308


   (Some context for this) I’m helping @andyfcx to work out a solution to #22152.
   
   The main problem with #22152 is that, when you set `render_template_as_native_obj` on a DAG, it would use a `NativeEnvironment` to create a Jinja2 template object, which in turn will be able to be rendered into a native object. However, the email-sending mechanism also uses the same Jinja2 environment, but this environment cannot correctly create a template to render into the email’s content (which must be a string, obviously).
   
   So the proposed solution here is to add an additional flag on `get_template_env` to control what environment to return. If `force_string` is True, `get_template_env` will always create a `SandboxedEnvironment` (which is rendered into a string), even if `render_template_as_native_obj` is True. A `NativeEnvironment` is used only if `render_template_as_native_obj` is True _and_ `force_string` is False.
   
   But the implementation in the PR still needs some work. I’m also not entirely convinced this is the best solution, and any suggestions are welcomed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org