Skip to content

[v3-3-test] Stop treating .jar, .whl and other zip-format files as Dag files - #74573

Closed
Aditya-XR wants to merge 1 commit into
apache:v3-3-testfrom
Aditya-XR:fix-zip-format-dag-discovery
Closed

Aditya-XR wants to merge 1 commit into
apache:v3-3-testfrom
Aditya-XR:fix-zip-format-dag-discovery

Conversation

@Aditya-XR

Copy link
Copy Markdown

On 3.3, Dag discovery decides whether a non-.py file is a zipped Dag with zipfile.is_zipfile() alone, without looking at the file name. .jar, .whl, .egg, .docx, .xlsx and plenty of other formats are zip containers, so any of them sitting in a Dags folder gets picked up as a Dag file. The Dag processor then queues it for parsing on every loop, the parse finds no importer for that extension and returns nothing, and the file shows up in parsing stats and airflow dags report with 0 Dags. #71125 has a report of this from a real deployment.

This goes straight to v3-3-test because there is nothing to cherry-pick: on main and v3-4-test the importer-based discovery already matches on file extension only.

Change: a non-.py file is only treated as a zipped Dag when its name ends in .zip (any case) and it is a valid zip archive. Applied to both discovery paths:

  • find_dag_file_paths in airflow/utils/file.py, used by the Dag processor via list_py_file_paths
  • PythonDagImporter.list_dag_files, used by DagBag.collect_dags

This makes the directory walk agree with the rest of 3.3, where the importer registry already picks an importer by file extension.

Behaviour notes

  • .zip and .ZIP archives are discovered exactly as before, and an invalid .zip is still skipped.
  • A zip archive whose name doesn't end in .zip (a bundle.zip.bak backup, a file with no extension, ...) is no longer discovered. Dags inside such files couldn't be loaded before either, because no importer is registered for those extensions, so nothing that works today stops working.
  • import_file and _get_observed_filelocs still use is_zipfile, but they only ever see files that discovery returned, so I left them alone to keep the patch small.

Testing

  • New parametrized tests for both discovery paths, each case a real archive containing a Dag-like file: .zip, .ZIP, .jar, .whl, .egg, .docx, .zip.bak and no extension. The six non-.zip cases fail on current v3-3-test and pass with the change.
  • airflow-core/tests/unit/utils/test_file.py and airflow-core/tests/unit/dag_processing/: 466 passed (450 existing + 16 new). The same 450 pass on the base branch.
  • prek on the changed files passes, including mypy for airflow-core.
  • Checked by hand with a Dags folder holding .zip and .ZIP bundles, a plain .py Dag, a directory named folder.zip/, a corrupt .zip, and a .jar, .whl, .docx and .zip.bak that each contain a Dag. Before, discovery returned 8 entries including all four non-.zip archives; after, only the .py, the two archives and the file inside folder.zip/. The set of loaded Dags is the same before and after.

related: #71125


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

Dag discovery treated any file that sniffed as a zip archive as a zipped
Dag, whatever its name. Formats such as .jar, .whl, .egg and .docx are zip
containers too, so each of them sitting in a Dags folder was queued for
parsing on every Dag processor loop, only to yield no Dags, and showed up
in parsing stats and in `airflow dags report`.

Zipped Dags can only be loaded from .zip files anyway, since the importer
registry picks an importer by file extension, and main already discovers
files by extension alone. Limiting the archive check to .zip makes
discovery agree with both.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 07:18
@boring-cyborg

boring-cyborg Bot commented Oct 12, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shahar1

shahar1 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Closing as we won't make additional 3.3 releases

@shahar1 shahar1 closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants