From c2577b64326054a3ec04ad9025ead8f87c9fba40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emin=20=C3=96zata?= Date: Fri, 30 Jan 2026 11:41:00 +0300 Subject: [PATCH] Fix airflowctl auth login failing with trailing slash in api-url (#61244) --- airflow-ctl/src/airflowctl/api/client.py | 1 + airflow-ctl/tests/airflow_ctl/api/test_client.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/airflow-ctl/src/airflowctl/api/client.py b/airflow-ctl/src/airflowctl/api/client.py index 5a719cac164cc..579d78ef0aa23 100644 --- a/airflow-ctl/src/airflowctl/api/client.py +++ b/airflow-ctl/src/airflowctl/api/client.py @@ -226,6 +226,7 @@ def _get_base_url( cls, base_url: str, kind: Literal[ClientKind.AUTH, ClientKind.CLI] = ClientKind.CLI ) -> str: """Get the base URL of the client.""" + base_url = base_url.rstrip("/") if kind == ClientKind.AUTH: return f"{base_url}/auth" return f"{base_url}/api/v2" diff --git a/airflow-ctl/tests/airflow_ctl/api/test_client.py b/airflow-ctl/tests/airflow_ctl/api/test_client.py index 39ffc436706c9..5913009ecd411 100644 --- a/airflow-ctl/tests/airflow_ctl/api/test_client.py +++ b/airflow-ctl/tests/airflow_ctl/api/test_client.py @@ -93,6 +93,10 @@ def handle_request(request: httpx.Request) -> httpx.Response: ("http://localhost:8080", ClientKind.AUTH, "http://localhost:8080/auth/"), ("https://example.com", ClientKind.CLI, "https://example.com/api/v2/"), ("https://example.com", ClientKind.AUTH, "https://example.com/auth/"), + ("http://localhost:8080/", ClientKind.CLI, "http://localhost:8080/api/v2/"), + ("http://localhost:8080/", ClientKind.AUTH, "http://localhost:8080/auth/"), + ("https://example.com/", ClientKind.CLI, "https://example.com/api/v2/"), + ("https://example.com/", ClientKind.AUTH, "https://example.com/auth/"), ], ) def test_refresh_base_url(self, base_url, client_kind, expected_base_url):