fix(airflow): add error handling around render_template() (#10907)

This commit is contained in:
Harshal Sheth 2024-07-16 12:27:37 -07:00 committed by GitHub
parent ff1c6b895e
commit bb24651264
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -362,8 +362,13 @@ class DataHubListener:
# 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]