diff --git a/cosmos/__init__.py b/cosmos/__init__.py index 182642d863..5d0cdcfc53 100644 --- a/cosmos/__init__.py +++ b/cosmos/__init__.py @@ -10,7 +10,7 @@ import importlib -__version__ = "1.14.1" +__version__ = "1.14.2a1" # Mapping of public names to their module paths for lazy loading via __getattr__. diff --git a/cosmos/plugin/airflow3.py b/cosmos/plugin/airflow3.py index 585b968dbf..ebf1d5f47d 100644 --- a/cosmos/plugin/airflow3.py +++ b/cosmos/plugin/airflow3.py @@ -142,7 +142,7 @@ def dbt_docs_view(slug_alias: str = slug) -> str: # type: ignore[no-redef] cfg_local = projects.get(slug_alias, {}) if not cfg_local.get("dir"): return "
dbt Docs are not configured.
" - iframe_src = f"/cosmos/{slug_alias}/dbt_docs_index.html" + iframe_src = f"{API_BASE_PATH}/cosmos/{slug_alias}/dbt_docs_index.html" safe_iframe_src = html.escape(iframe_src, quote=True) return ( '
' diff --git a/tests/plugin/test_plugin_af3.py b/tests/plugin/test_plugin_af3.py index 54afd2e60a..3bc4753292 100644 --- a/tests/plugin/test_plugin_af3.py +++ b/tests/plugin/test_plugin_af3.py @@ -130,6 +130,25 @@ def test_manifest_and_catalog_error_500(tmp_path: Path): assert "catalog read failed" in r.text +@skip_pre_airflow_31 +def test_dbt_docs_view_iframe_src_uses_api_base_path(tmp_path: Path): + # Regression: iframe src must include the deployment path prefix (e.g. Astronomer /de3jzcwo) + # so browsers don't strip it and hit the wrong URL. + docs_dir = tmp_path / "target" + docs_dir.mkdir(parents=True) + (docs_dir / "index.html").write_text("dbt") + + af3 = _reload_af3_module(api_base="https://host/de3jzcwo") + projects = {"core": {"dir": str(docs_dir), "index": "index.html"}} + with patch("cosmos.plugin.airflow3._load_projects_from_conf", return_value=projects): + app = af3.create_cosmos_fastapi_app() + + client = TestClient(app) + r = client.get("/core/dbt_docs") + assert r.status_code == 200 + assert "/de3jzcwo/cosmos/core/dbt_docs_index.html" in r.text + + @skip_pre_airflow_31 def test_external_view_href_uses_api_base_path(): # Ensure base path is respected (e.g., Astronomer deployment prefix)