This is an automated email from the ASF dual-hosted git repository.
vatsrahul1001 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 b59f7489cd8 Make ZIP_REGEX case-insensitive to match .ZIP archives
(#74269)
b59f7489cd8 is described below
commit b59f7489cd8532f189099d65dccc576ffb57c0f5
Author: Subham <[email protected]>
AuthorDate: Sun Oct 18 12:07:09 2026 +0530
Make ZIP_REGEX case-insensitive to match .ZIP archives (#74269)
* Make ZIP_REGEX case-insensitive to match .ZIP archives
closes: #74060
* Simplify and parameterize uppercase ZIP tests
---
airflow-core/src/airflow/utils/file.py | 2 +-
airflow-core/tests/unit/utils/test_file.py | 16 ++++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/airflow-core/src/airflow/utils/file.py
b/airflow-core/src/airflow/utils/file.py
index 9dd55f462de..4f2eb3b7faf 100644
--- a/airflow-core/src/airflow/utils/file.py
+++ b/airflow-core/src/airflow/utils/file.py
@@ -32,7 +32,7 @@ from airflow._shared.module_loading import (
might_contain_dag_via_default_heuristic as
might_contain_dag_via_default_heuristic,
)
-ZIP_REGEX = re.compile(rf"((.*\.zip){re.escape(os.sep)})?(.*)")
+ZIP_REGEX = re.compile(rf"((.*\.zip){re.escape(os.sep)})?(.*)", re.IGNORECASE)
@overload
diff --git a/airflow-core/tests/unit/utils/test_file.py
b/airflow-core/tests/unit/utils/test_file.py
index 38fcd1534ac..3b6bd773164 100644
--- a/airflow-core/tests/unit/utils/test_file.py
+++ b/airflow-core/tests/unit/utils/test_file.py
@@ -59,18 +59,19 @@ class TestCorrectMaybeZipped:
assert dag_folder == path
+ @pytest.mark.parametrize("archive", ["/path/to/archive.zip",
"/path/to/archive.ZIP"])
@mock.patch("zipfile.is_zipfile")
- def test_correct_maybe_zipped_archive(self, mocked_is_zipfile):
- path = "/path/to/archive.zip/deep/path/to/file.txt"
+ def test_correct_maybe_zipped_archive(self, mocked_is_zipfile, archive):
+ path = f"{archive}/deep/path/to/file.txt"
mocked_is_zipfile.return_value = True
dag_folder = correct_maybe_zipped(path)
assert mocked_is_zipfile.call_count == 1
(args, kwargs) = mocked_is_zipfile.call_args_list[0]
- assert args[0] == "/path/to/archive.zip"
+ assert args[0] == archive
- assert dag_folder == "/path/to/archive.zip"
+ assert dag_folder == archive
class TestOpenMaybeZipped:
@@ -92,6 +93,13 @@ class TestOpenMaybeZipped:
content = test_file.read()
assert isinstance(content, str)
+ def test_open_maybe_zipped_archive_uppercase_extension(self,
test_zip_path):
+ uppercase_zip = os.path.splitext(test_zip_path)[0] + ".ZIP"
+ os.rename(test_zip_path, uppercase_zip)
+ with open_maybe_zipped(os.path.join(uppercase_zip, "test_zip.py"),
"r") as test_file:
+ content = test_file.read()
+ assert isinstance(content, str)
+
class TestDagFileHelpers:
def test_find_path_from_directory_regex_ignore(self):