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

potiuk 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 3f8ac22caf Print the key name when max_length is exceeded (#43061)
3f8ac22caf is described below

commit 3f8ac22cafa6bfe3c61da781f8bc7de9bca9bd47
Author: Mike <[email protected]>
AuthorDate: Thu Oct 17 03:48:16 2024 -0400

    Print the key name when max_length is exceeded (#43061)
    
    * Print the key name when max_length is exceeded
    
    * Fix tests
---
 airflow/utils/helpers.py     | 2 +-
 tests/utils/test_helpers.py  | 2 +-
 tests/www/test_validators.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/airflow/utils/helpers.py b/airflow/utils/helpers.py
index 8c08acc66b..8b83e3b134 100644
--- a/airflow/utils/helpers.py
+++ b/airflow/utils/helpers.py
@@ -50,7 +50,7 @@ def validate_key(k: str, max_length: int = 250):
     if not isinstance(k, str):
         raise TypeError(f"The key has to be a string and is {type(k)}:{k}")
     if len(k) > max_length:
-        raise AirflowException(f"The key has to be less than {max_length} 
characters")
+        raise AirflowException(f"The key: {k} has to be less than {max_length} 
characters")
     if not KEY_REGEX.match(k):
         raise AirflowException(
             f"The key {k!r} has to be made of alphanumeric characters, dashes, 
"
diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py
index 041dba2a90..ed1b1134d8 100644
--- a/tests/utils/test_helpers.py
+++ b/tests/utils/test_helpers.py
@@ -203,7 +203,7 @@ class TestHelpers:
                 "characters, dashes, dots and underscores exclusively",
                 AirflowException,
             ),
-            (" " * 251, "The key has to be less than 250 characters", 
AirflowException),
+            (" " * 251, f"The key: {' ' * 251} has to be less than 250 
characters", AirflowException),
         ],
     )
     def test_validate_key(self, key_id, message, exception):
diff --git a/tests/www/test_validators.py b/tests/www/test_validators.py
index e92cc9d804..02923f9e2a 100644
--- a/tests/www/test_validators.py
+++ b/tests/www/test_validators.py
@@ -151,7 +151,7 @@ class TestValidKey:
 
         with pytest.raises(
             validators.ValidationError,
-            match=r"The key has to be less than [0-9]+ characters",
+            match=r"The key: [x]+ has to be less than [0-9]+ characters",
         ):
             self._validate()
 

Reply via email to