Repository navigation
Description
Description
find_dag_file_paths (airflow-core/src/airflow/utils/file.py) decides whether to attempt DAG discovery on a file using:
if path.is_file() and (path.suffix == ".py" or zipfile.is_zipfile(path)):
if might_contain_dag(file_path, safe_mode):
file_paths.append(file_path)zipfile.is_zipfile() is a content sniff (checks for the PK zip magic bytes/central directory), not an extension check. There is no accompanying path.suffix == ".zip" condition. Since the ZIP format underlies many common file types beyond .zip itself — .jar, .pptx, .docx, .xlsx, .apk, .epub, .odt, .whl, etc. — any of these dropped into a DAGs folder (e.g. a build artifact, a supporting doc, a packaged dependency) will pass this check and get opened and scanned via might_contain_dag, purely because it happens to share the underlying zip container format with Airflow's own zipped-DAG-bundle feature.
This was reported previously in #45718 with a .pptx file, but that issue was closed as invalid because the specific symptom described there (garbled metric names) turned out to be an unrelated stat-sanitization bug, not this zip-detection design question. The zip-detection behavior itself was never actually addressed.
Impact
At minimum this is wasted work (opening and scanning irrelevant files on every DAG processor cycle). Depending on might_contain_dag's heuristic and the archive's contents, it can also produce confusing log noise, and in the originally reported case, appears able to feed corrupted/unexpected data further into DAG processing.
What you think should happen instead
Gate the zip-bundle branch on the file extension in addition to (or instead of) the content sniff, e.g.:
if path.is_file() and (path.suffix == ".py" or (path.suffix == ".zip" and zipfile.is_zipfile(path))):This preserves the documented .zip DAG-bundle behavior while no longer opening arbitrary non-.zip files that merely share the same underlying container format. .airflowignore is a viable per-deployment workaround today (matching by extension), but it means every deployment that happens to keep e.g. .jar files anywhere under its DAGs folder has to know to add this rule proactively rather than it being a non-issue by default.
How to reproduce
- Place any non-
.zipPK-zip-format file (a.jar,.pptx,.docx, etc.) anywhere under the DAGs folder. - Wait for the DAG processor to walk the directory.
- Observe that the file is opened and passed through
might_contain_dag(visible via DAG processor debug logs), the same as a.zipDAG bundle would be, despite not being one.
Are you willing to submit a PR?
- Yes
Code of Conduct
- I agree to follow this project's Code of Conduct
Drafted-by: Claude Code (Sonnet 5); reviewed by @seanmuth before posting
Activity
seanmuth commentedon Aug 4, 2026
simple PR with some added tests incoming.
seanmuth commentedon Aug 4, 2026
Update: this has surfaced in production with concrete impact beyond "wasted work." A customer's DAG processor logs showed individual
.jarfiles taking 60+ seconds each to "parse," producing zero DAGs. That's real DAG-processor loop budget being consumed scanning archive internals that were never going to yield a DAG, plausibly contributing to unrelated DAGs in the same folder going stale/missing under the processor's timeout budget — not just log noise as originally described above.Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
seanmuth commentedon Aug 4, 2026
Further data point from the same production environment (
airflow dags report-style output, file paths/timings only, otherwise anonymized):Two things worth noting:
.jar— a.whl(Python wheel, also PK-zip format) shows up too, confirming this affects the full family of zip-container formats from the original file-signature table (DAG Processing Processor attempts to parse PPTX (and other non-code based ZIP archives) based on zipfile.is_zipfile design #45718), not just.jarspecifically..pyDAG files with real errors are landing in the same 60-64s band as the bogus.jar/.whlentries. I want to be careful not to overclaim causation here — these DAGs may simply be slow/erroring independently (heavy top-level code or third-party imports of their own), and this data alone doesn't prove the zip-format files are consuming shared processor budget from them. But the timing coincidence is close enough that it seems worth someone checking whether there's an interaction, in addition to the baseline "these files should never have been candidates at all."Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
jason810496 commentedon Aug 5, 2026
The further AIP-85 DagImporter interface might solve this problem fundamentally.
Fix newsfragment PR number for apache#71166
Aditya-XR commentedon Oct 12, 2026
3.3.x is still affected, but
mainandv3-4-testaren't anymore: discovery there goes through the new importers and matches on file extension only, without sniffing file contents.On
v3-3-testthe content sniff is in two places,find_dag_file_paths(Dag processor) andPythonDagImporter.list_dag_files(DagBag). I opened #74573 againstv3-3-testso that only.zipfiles (any case) that are valid archives are treated as zipped Dags, with regression tests for.jar,.whl,.eggand.docxon both paths.Since
mainis already fixed, I think this issue can be closed once that change ships in a 3.3.x release.Drafted-by: Claude Code (Opus 5.5); reviewed by @Aditya-XR before posting