Skip to content

DAG processor treats any zip-format file (.jar, .pptx, .docx, .xlsx, etc.) as a potential DAG bundle, not just .zip #71125

Open

Description

@seanmuth

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

  1. Place any non-.zip PK-zip-format file (a .jar, .pptx, .docx, etc.) anywhere under the DAGs folder.
  2. Wait for the DAG processor to walk the directory.
  3. Observe that the file is opened and passed through might_contain_dag (visible via DAG processor debug logs), the same as a .zip DAG 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

  1. added
    kind:bug
    on Aug 4, 2026
  2. seanmuth commented on Aug 4, 2026

    @seanmuth
    ContributorAuthor

    simple PR with some added tests incoming.

  3. seanmuth commented on Aug 4, 2026

    @seanmuth
    ContributorAuthor

    Update: this has surfaced in production with concrete impact beyond "wasted work." A customer's DAG processor logs showed individual .jar files 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)

  4. seanmuth commented on Aug 4, 2026

    @seanmuth
    ContributorAuthor

    Further data point from the same production environment (airflow dags report-style output, file paths/timings only, otherwise anonymized):

    File Path                                    # DAGs   # Errors   Last Runtime
    gfs-mi-reporting-4.0.jar                     0        0          74.26s
    gfs-mi-reporting-snapshot.jar                0        0          70.64s
    gfs-mi-reporting-3.5.jar                     0        0          69.63s
    gfs-mi-reporting-5.0.0.jar                   0        0          68.77s
    airflow_platform_plugins-2.11.0-py3-none-any.whl   0  0          68.45s
    nvsins_anomaly_notification_internal.py      0        1          64.00s
    providersafe_auth_user_pipeline_dag.py       0        1          63.45s
    gdds_hourly_load.py                          0        1          62.51s
    edh_data_usage_pipeline_dag.py               0        1          62.49s
    nvoei_hourly_load.py                         0        1          62.04s
    gfs-mi-reporting-4.1.jar                     0        0          62.04s
    test_dag.py                                  1        0          61.07s
    idw-edh-etl-snapshot.jar                     0        0          60.24s
    idw-edh-etl-4.0.0.jar                        0        0          11.77s
    

    Two things worth noting:

    1. It's not just .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 .jar specifically.
    2. Several actual .py DAG files with real errors are landing in the same 60-64s band as the bogus .jar/.whl entries. 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)

  5. jason810496 commented on Aug 5, 2026

    @jason810496
    Member

    The further AIP-85 DagImporter interface might solve this problem fundamentally.

  6. added a commit that references this issue on Aug 16, 2026
    52c5e60
  7. Aditya-XR commented on Oct 12, 2026

    @Aditya-XR

    3.3.x is still affected, but main and v3-4-test aren't anymore: discovery there goes through the new importers and matches on file extension only, without sniffing file contents.

    On v3-3-test the content sniff is in two places, find_dag_file_paths (Dag processor) and PythonDagImporter.list_dag_files (DagBag). I opened #74573 against v3-3-test so that only .zip files (any case) that are valid archives are treated as zipped Dags, with regression tests for .jar, .whl, .egg and .docx on both paths.

    Since main is 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected_version:3.3area:corearea:dag-bundlesarea:dag-processorkind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions