tirkarthi commented on issue #23333:
URL: https://github.com/apache/airflow/issues/23333#issuecomment-1112524103

   jinja doesn't include searchpath in the error message. The exception 
probably needs to be caught at Airflow side to reraise with searchpath appended.
   
   ```diff
   diff --git a/airflow/models/abstractoperator.py 
b/airflow/models/abstractoperator.py
   index 2c53a8b75..e70b37001 100644
   --- a/airflow/models/abstractoperator.py
   +++ b/airflow/models/abstractoperator.py
   @@ -382,7 +382,13 @@ class AbstractOperator(LoggingMixin, DAGNode):
    
            if isinstance(value, str):
                if any(value.endswith(ext) for ext in self.template_ext):  # A 
filepath.
   -                template = jinja_env.get_template(value)
   +                from jinja2.exceptions import TemplateNotFound
   +
   +                try:
   +                    template = jinja_env.get_template(value)
   +                except TemplateNotFound as e:
   +                    message = f"{value} not found in search path 
{jinja_env.loader.searchpath}"
   +                    raise TemplateNotFound(message)
                else:
                    template = jinja_env.from_string(value)
                dag = self.get_dag()
   ```
   
   ```
   jinja2.exceptions.TemplateNotFound: /tmp/a/python_template_exts.txt not 
found in search path ['/opt/airflow/tests/operators', '/']
   ```


-- 
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