diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/backfills.py b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/backfills.py index 36329c03a718f..c4c7ffe79a7fc 100644 --- a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/backfills.py +++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/backfills.py @@ -20,6 +20,7 @@ from fastapi import Depends, status from sqlalchemy import select +from sqlalchemy.orm import joinedload from airflow.api_fastapi.common.db.common import SessionDep, paginated_select from airflow.api_fastapi.common.parameters import ( @@ -64,7 +65,7 @@ def list_backfills_ui( ], ) -> BackfillCollectionResponse: select_stmt, total_entries = paginated_select( - statement=select(Backfill), + statement=select(Backfill).options(joinedload(Backfill.dag_model)), filters=[dag_id, active], order_by=order_by, offset=offset, diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_backfills.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_backfills.py index 5e355f83b66ee..8b7bdde96d577 100644 --- a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_backfills.py +++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_backfills.py @@ -25,6 +25,7 @@ from airflow.models.backfill import Backfill from airflow.utils.session import provide_session +from tests_common.test_utils.asserts import assert_queries_count from tests_common.test_utils.db import ( clear_db_backfills, clear_db_dag_bundles, @@ -152,7 +153,8 @@ def test_should_response_200( expected_response = [] for backfill in response_params: expected_response.append(backfill_responses[backfill]) - response = test_client.get("/backfills", params=test_params) + with assert_queries_count(2): + response = test_client.get("/backfills", params=test_params) assert response.status_code == 200 assert response.json() == { "backfills": expected_response,