Skip to content

Commit

Permalink
fix(airflow): add error handling around render_template() (#10907)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Jul 16, 2024
1 parent ff1c6b8 commit bb24651
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,13 @@ def on_task_instance_running(

# Render templates in a copy of the task instance.
# This is necessary to get the correct operator args in the extractors.
task_instance = copy.deepcopy(task_instance)
task_instance.render_templates()
try:
task_instance = copy.deepcopy(task_instance)
task_instance.render_templates()
except Exception as e:
logger.info(
f"Error rendering templates in DataHub listener. Jinja-templated variables will not be extracted correctly: {e}"
)

# The type ignore is to placate mypy on Airflow 2.1.x.
dagrun: "DagRun" = task_instance.dag_run # type: ignore[attr-defined]
Expand Down

0 comments on commit bb24651

Please sign in to comment.