This is an automated email from the ASF dual-hosted git repository.
kaxil 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 5d1c1d42328 Load Common AI plugin tabs when the browser reaches
Airflow on another origin (#75522)
5d1c1d42328 is described below
commit 5d1c1d42328d015473a637ba72c0f51d7546066f
Author: Kaxil Naik <[email protected]>
AuthorDate: Fri Oct 23 23:53:12 2026 +0100
Load Common AI plugin tabs when the browser reaches Airflow on another
origin (#75522)
get_bundle_url copied the scheme and host of [api] base_url into the plugin
bundle URL. When the browser reached Airflow on a different origin, such as
through a local proxy, the AI Model and HITL Review tabs imported their
bundle
cross-origin and rendered empty. Return only the path, which the host UI
resolves against the page it was loaded from.
---
.../providers/common/ai/plugins/_plugin_urls.py | 13 ++++---------
.../unit/common/ai/plugins/test__plugin_urls.py | 22 ++++++++++++++--------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git
a/providers/common/ai/src/airflow/providers/common/ai/plugins/_plugin_urls.py
b/providers/common/ai/src/airflow/providers/common/ai/plugins/_plugin_urls.py
index a1e8517d514..f9d2ca2ba0a 100644
---
a/providers/common/ai/src/airflow/providers/common/ai/plugins/_plugin_urls.py
+++
b/providers/common/ai/src/airflow/providers/common/ai/plugins/_plugin_urls.py
@@ -38,13 +38,8 @@ def get_bundle_url(plugin_prefix: str, bundle_filename: str)
-> str:
"""
Return the bundle URL for a plugin's React bundle.
- Uses an absolute URL when api.base_url is a full URL so the bundle loads
- correctly in Vite dev mode, where import() resolves relative to the script
- origin (5173) rather than the document origin (28080).
+ Only the path is used, never the origin in api.base_url: the host UI
resolves it against the
+ page it was loaded from, so the bundle still loads when the browser
reaches Airflow through
+ a different origin than base_url names, such as a local proxy.
"""
- path = get_base_url_path(f"{plugin_prefix}/static/{bundle_filename}")
- base_url = conf.get("api", "base_url", fallback="/")
- if base_url.startswith(("http://", "https://")):
- parsed = urlparse(base_url)
- return f"{parsed.scheme}://{parsed.netloc}" + path
- return path
+ return get_base_url_path(f"{plugin_prefix}/static/{bundle_filename}")
diff --git
a/providers/common/ai/tests/unit/common/ai/plugins/test__plugin_urls.py
b/providers/common/ai/tests/unit/common/ai/plugins/test__plugin_urls.py
index a586cdbfe9f..896f3935558 100644
--- a/providers/common/ai/tests/unit/common/ai/plugins/test__plugin_urls.py
+++ b/providers/common/ai/tests/unit/common/ai/plugins/test__plugin_urls.py
@@ -16,6 +16,8 @@
# under the License.
from __future__ import annotations
+import pytest
+
from airflow.providers.common.ai.plugins._plugin_urls import
get_base_url_path, get_bundle_url
from tests_common.test_utils.config import conf_vars
@@ -36,11 +38,15 @@ class TestGetBundleUrl:
with conf_vars({("api", "base_url"): "/"}):
assert get_bundle_url("/ai-model", "model.umd.cjs") ==
"/ai-model/static/model.umd.cjs"
- def test_http_base_url_returns_an_absolute_url(self):
- """An absolute bundle_url is needed in Vite dev mode, where import()
resolves
- relative to the script origin (5173), not the document origin
(28080)."""
- with conf_vars({("api", "base_url"): "http://example.com/airflow/"}):
- assert (
- get_bundle_url("/ai-model", "model.umd.cjs")
- == "http://example.com/airflow/ai-model/static/model.umd.cjs"
- )
+ @pytest.mark.parametrize(
+ ("base_url", "expected"),
+ [
+ ("http://localhost:8080", "/ai-model/static/model.umd.cjs"),
+ ("http://example.com/airflow/",
"/airflow/ai-model/static/model.umd.cjs"),
+ ],
+ )
+ def test_http_base_url_keeps_only_the_path(self, base_url, expected):
+ """The browser may reach Airflow on another origin than base_url names
(a local proxy),
+ so the bundle URL must not carry base_url's scheme and host."""
+ with conf_vars({("api", "base_url"): base_url}):
+ assert get_bundle_url("/ai-model", "model.umd.cjs") == expected