This is an automated email from the ASF dual-hosted git repository.

jscheffl 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 805473d4061 Sanitise password in logs while parsing connection from 
URI (#62180)
805473d4061 is described below

commit 805473d4061bacc41800e691e257b04a562bb471
Author: stephen-bracken <[email protected]>
AuthorDate: Tue Feb 24 21:44:46 2026 +0000

    Sanitise password in logs while parsing connection from URI (#62180)
    
    Co-authored-by: Stephen Bracken <email-protected>
---
 airflow-core/src/airflow/models/connection.py     |  4 ++--
 airflow-core/tests/unit/models/test_connection.py | 26 +++++++++++++++++++++--
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/airflow-core/src/airflow/models/connection.py 
b/airflow-core/src/airflow/models/connection.py
index 29b5e0be1ae..0e1505f4667 100644
--- a/airflow-core/src/airflow/models/connection.py
+++ b/airflow-core/src/airflow/models/connection.py
@@ -226,7 +226,7 @@ class Connection(Base, LoggingMixin):
     def _parse_from_uri(self, uri: str):
         schemes_count_in_uri = uri.count("://")
         if schemes_count_in_uri > 2:
-            raise AirflowException(f"Invalid connection string: {uri}.")
+            raise AirflowException("Invalid connection string.")
         host_with_protocol = schemes_count_in_uri == 2
         uri_parts = urlsplit(uri)
         conn_type = uri_parts.scheme
@@ -235,7 +235,7 @@ class Connection(Base, LoggingMixin):
         if host_with_protocol:
             uri_splits = rest_of_the_url.split("://", 1)
             if "@" in uri_splits[0] or ":" in uri_splits[0]:
-                raise AirflowException(f"Invalid connection string: {uri}.")
+                raise AirflowException("Invalid connection string.")
         uri_parts = urlsplit(rest_of_the_url)
         protocol = uri_parts.scheme if host_with_protocol else None
         host = _parse_netloc_to_hostname(uri_parts)
diff --git a/airflow-core/tests/unit/models/test_connection.py 
b/airflow-core/tests/unit/models/test_connection.py
index 1f14c325ea9..6e0f9efbcd3 100644
--- a/airflow-core/tests/unit/models/test_connection.py
+++ b/airflow-core/tests/unit/models/test_connection.py
@@ -138,7 +138,7 @@ class TestConnection:
                 {"param": "value"},
                 None,
             ),
-            (
+            (  # Test password sanitisation
                 "type://user:pass@protocol://host:port?param=value",
                 None,
                 None,
@@ -147,7 +147,29 @@ class TestConnection:
                 None,
                 None,
                 None,
-                r"Invalid connection string: 
type://user:pass@protocol://host:port?param=value.",
+                r"Invalid connection string.",
+            ),
+            (
+                "foo:pwd@host://://",
+                None,
+                None,
+                None,
+                None,
+                None,
+                None,
+                None,
+                r"Invalid connection string.",
+            ),
+            (
+                "type://:foo@host/://://",
+                None,
+                None,
+                None,
+                None,
+                None,
+                None,
+                None,
+                r"Invalid connection string.",
             ),
             (
                 
"type://host?int_param=123&bool_param=true&float_param=1.5&str_param=some_str",

Reply via email to