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/08/02 05:31:50 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #25452: Issue 25344: Improve Airflow logging for operator Jinja template processing

uranusjr commented on code in PR #25452:
URL: https://github.com/apache/airflow/pull/25452#discussion_r935129238


##########
airflow/models/abstractoperator.py:
##########
@@ -345,13 +349,22 @@ def _do_render_template_fields(
                 )
             if not value:
                 continue
-            rendered_content = self.render_template(
-                value,
-                context,
-                jinja_env,
-                seen_oids,
-            )
-            setattr(parent, attr_name, rendered_content)
+            try:
+                rendered_content = self.render_template(
+                    value,
+                    context,
+                    jinja_env,
+                    seen_oids,
+                )
+            except Exception:
+                logger.exception(
+                    f"Exception rendering Jinja template for in "
+                    f"task '{self.task_id}', field "
+                    f"'{attr_name}'. Template: {value!r}"
+                )

Review Comment:
   I think `self.log.exception` is better here; `baseoperator` needed an additional `logger` for free functions outside a class, but this inherits `LoggingMixin` and does not need it.



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