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


##########
airflow/models/abstractoperator.py:
##########
@@ -564,8 +564,18 @@ def _do_render_template_fields(
                     f"{attr_name!r} is configured as a template field "
                     f"but {parent.task_type} does not have this attribute."
                 )
-            if not value:
+
+            try:
+                if not value:
+                    continue
+            except ValueError:
+                # This may happen if the templated field points to a class 
which does not
+                # support `__bool__`, such as Pandas DataFrames:
+                # 
https://github.com/pandas-dev/pandas/blob/2.0.x/pandas/core/generic.py#L1465
+                # The assumption, in these cases, is that we do not know how 
to render the
+                # templated field, and we should continue.
                 continue

Review Comment:
   I wonder if we should just catch everything here, instead of just 
ValueError. Another thing is maybe it would be better to `pass` instead of 
`continue`? The `if not` check is essentially a shortcut to avoid drilling into 
falsy values, but if an object raises an exception on the check, it may be 
safer to assume it’s truthy instead of falsy.



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