You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Subham-KRLX (via GitHub)" <gi...@apache.org> on 2026/10/05 15:19:06 UTC
[PR] Make ZIP_REGEX case-insensitive to match .ZIP archives [airflow]
Subham-KRLX opened a new pull request, #74269:
URL: https://github.com/apache/airflow/pull/74269
Dag discovery accepts packaged Dags ending in `.ZIP`, but `ZIP_REGEX` in `airflow/utils/file.py` only matched lowercase `.zip`. As a result, `correct_maybe_zipped` and `open_maybe_zipped` failed to treat `.ZIP` archives as zip files, causing `DagCode` to raise `NotADirectoryError` when reading back the Dag source.
This PR adds `re.IGNORECASE` to `ZIP_REGEX` and adds unit tests covering uppercase `.ZIP` archives for both `correct_maybe_zipped` and `open_maybe_zipped`.
closes: #74060
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (Claude Code for code research and PR description)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make ZIP_REGEX case-insensitive to match .ZIP archives [airflow]
Posted by "rjgoyln (via GitHub)" <gi...@apache.org>.
rjgoyln commented on code in PR #74269:
URL: https://github.com/apache/airflow/pull/74269#discussion_r4194857314
##########
airflow-core/tests/unit/utils/test_file.py:
##########
@@ -72,6 +72,19 @@ def test_correct_maybe_zipped_archive(self, mocked_is_zipfile):
assert dag_folder == "/path/to/archive.zip"
+ @mock.patch("zipfile.is_zipfile")
+ def test_correct_maybe_zipped_archive_uppercase_extension(self, mocked_is_zipfile):
Review Comment:
Small consolidation thought: this is identical to `test_correct_maybe_zipped_archive` above, except for the archive name.
Could we parameterize the existing test instead, so both `.zip` and `.ZIP` stay in sync if the assertions change?
```python
@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, archive):
...
```
I tried this locally: both cases pass with the change, and `.ZIP` fails without it.
##########
airflow-core/tests/unit/utils/test_file.py:
##########
@@ -92,6 +105,21 @@ def test_open_maybe_zipped_archive(self, test_zip_path):
content = test_file.read()
assert isinstance(content, str)
+ def test_open_maybe_zipped_archive_uppercase_extension(self, tmp_path):
Review Comment:
Could we reuse the existing `test_zip_path` fixture here? The current test re-implements the ZIP setup already provided by `airflow-core/tests/conftest.py`.
We could just rename the fixture's archive to `.ZIP` and keep the test focused on the new case:
```python
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)
```
I tried this locally, and it still fails with `NotADirectoryError` without the regex change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make ZIP_REGEX case-insensitive to match .ZIP archives [airflow]
Posted by "Subham-KRLX (via GitHub)" <gi...@apache.org>.
Subham-KRLX commented on code in PR #74269:
URL: https://github.com/apache/airflow/pull/74269#discussion_r4197665570
##########
airflow-core/tests/unit/utils/test_file.py:
##########
@@ -72,6 +72,19 @@ def test_correct_maybe_zipped_archive(self, mocked_is_zipfile):
assert dag_folder == "/path/to/archive.zip"
+ @mock.patch("zipfile.is_zipfile")
+ def test_correct_maybe_zipped_archive_uppercase_extension(self, mocked_is_zipfile):
Review Comment:
Good point Parameterized the test across both `.zip` and `.ZIP` cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make ZIP_REGEX case-insensitive to match .ZIP archives [airflow]
Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 merged PR #74269:
URL: https://github.com/apache/airflow/pull/74269
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make ZIP_REGEX case-insensitive to match .ZIP archives [airflow]
Posted by "Subham-KRLX (via GitHub)" <gi...@apache.org>.
Subham-KRLX commented on code in PR #74269:
URL: https://github.com/apache/airflow/pull/74269#discussion_r4197673947
##########
airflow-core/tests/unit/utils/test_file.py:
##########
@@ -92,6 +105,21 @@ def test_open_maybe_zipped_archive(self, test_zip_path):
content = test_file.read()
assert isinstance(content, str)
+ def test_open_maybe_zipped_archive_uppercase_extension(self, tmp_path):
Review Comment:
Updated to reuse `test_zip_path` and rename with `os.rename`. Much cleaner.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make ZIP_REGEX case-insensitive to match .ZIP archives [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #74269:
URL: https://github.com/apache/airflow/pull/74269#issuecomment-6247695278
### Backport successfully created: v3-4-test
Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>✅</td>
<td>v3-4-test</td>
<td><a href="https://github.com/apache/airflow/pull/74967"><img src="https://img.shields.io/badge/PR-74967-blue" alt="PR Link"></a></td>
</tr>
</table>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org