This is an automated email from the ASF dual-hosted git repository.
ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 3df86abc26b Fix Error when viewing Dag details of a no longer
configured bundle (#52086)
3df86abc26b is described below
commit 3df86abc26bbd4d5ebeb80a38e7267ea1007754f
Author: Ephraim Anierobi <[email protected]>
AuthorDate: Mon Jun 23 22:28:54 2025 +0100
Fix Error when viewing Dag details of a no longer configured bundle (#52086)
* Fix Error when viewing Dag details of a no longer configured bundle
When a dag bundle is no longer configured, we raise error when accessing
the dagbundle view url. This affects the UI and the fix I propose is to
catch this error and return a message instead indicating that the bundle
is no longer configured
* fixup! Fix Error when viewing Dag details of a no longer configured bundle
---
.../airflow/api_fastapi/core_api/datamodels/dag_versions.py | 5 ++++-
.../api_fastapi/core_api/routes/public/test_dag_versions.py | 12 ++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_versions.py
b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_versions.py
index 6f255641aaa..09a18f8a4fc 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_versions.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_versions.py
@@ -41,7 +41,10 @@ class DagVersionResponse(BaseModel):
@property
def bundle_url(self) -> str | None:
if self.bundle_name:
- return DagBundlesManager().view_url(self.bundle_name,
self.bundle_version)
+ try:
+ return DagBundlesManager().view_url(self.bundle_name,
self.bundle_version)
+ except ValueError:
+ return None
return None
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_versions.py
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_versions.py
index f4b34f8c548..bb363475b94 100644
---
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_versions.py
+++
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_versions.py
@@ -108,6 +108,18 @@ class TestGetDagVersion(TestDagVersionEndpoint):
assert response.status_code == 200
assert response.json() == expected_response
+ @pytest.mark.usefixtures("make_dag_with_multiple_versions")
+
@mock.patch("airflow.dag_processing.bundles.manager.DagBundlesManager.view_url")
+ def test_get_dag_version_with_unconfigured_bundle(self, mock_view_url,
test_client, dag_maker, session):
+ """Test that when a bundle is no longer configured, the bundle_url
returns an error message."""
+ mock_view_url.side_effect = ValueError("Bundle not configured")
+
+ response =
test_client.get("/dags/dag_with_multiple_versions/dagVersions/1")
+ assert response.status_code == 200
+
+ response_data = response.json()
+ assert not response_data["bundle_url"]
+
def test_get_dag_version_404(self, test_client):
response =
test_client.get("/dags/dag_with_multiple_versions/dagVersions/99")
assert response.status_code == 404