Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash an error msg instead of failure in rendered-templates when map index is not found #32011

Merged
merged 2 commits into from
Jun 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,9 @@ def rendered_templates(self, session):
dag_run = dag.get_dagrun(execution_date=dttm, session=session)
raw_task = dag.get_task(task_id).prepare_for_execution()

title = "Rendered Template"
html_dict = {}

ti: TaskInstance
if dag_run is None:
# No DAG run matching given logical date. This usually means this
Expand All @@ -1419,7 +1422,21 @@ def rendered_templates(self, session):
ti.dag_run = DagRun(dag_id=dag_id, execution_date=dttm)
else:
ti = dag_run.get_task_instance(task_id=task_id, map_index=map_index, session=session)
ti.refresh_from_task(raw_task)
if ti:
ti.refresh_from_task(raw_task)
else:
flash(f"there is no task instance with the provided map_index {map_index}", "error")
return self.render_template(
"airflow/ti_code.html",
html_dict=html_dict,
dag=dag,
task_id=task_id,
execution_date=execution_date,
map_index=map_index,
form=form,
root=root,
title=title,
)

try:
ti.get_rendered_template_fields(session=session)
Expand All @@ -1439,8 +1456,6 @@ def rendered_templates(self, session):
# but we'll display some quasi-meaingful field names.
task = ti.task.unmap(None)

title = "Rendered Template"
html_dict = {}
renderers = wwwutils.get_attr_renderer()

for template_field in task.template_fields:
Expand Down