uranusjr edited a comment 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. 
Also at least one test will be needed.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to