GitHub user noderat added a comment to the discussion: microsoft-psrp 
securestring jinja2.exceptions.TemplateAssertionError

I'm pretty sure this is a bug and that this operator extends the wrong method 
on BaseOperator to add the template filter. I tossed this together and it looks 
like it fixes things, but since I'm not all that familiar with Airflow and this 
is my first attempt at doing any kind of Airflow work I'll leave this snippet 
to the experts to decide if it is indeed a bug and if this is the correct 
resolution:

```python
    def render_template_fields(
            self,
            context: Context,
            jinja_env: jinja2.Environment | None = None,
        ) -> None:

            if not jinja_env:
                jinja_env = self.get_template_env()

            native = isinstance(jinja_env, NativeEnvironment)
            def securestring(value: str):
                if not native:
                    raise AirflowException(
                        "Filter 'securestring' not applicable to non-native 
templating environment"
                    )
                return TaggedValue("SS", value)
            jinja_env.filters["securestring"] = securestring

            self._do_render_template_fields(self, self.template_fields, 
context, jinja_env, set())
```

GitHub link: 
https://github.com/apache/airflow/discussions/44095#discussioncomment-11328102

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to