Skip to content

Conversation

@seruman
Copy link

@seruman seruman commented Nov 26, 2025

Fixes negation patterns in .airflowignore not working for subdirectories when
using glob syntax.

From docs;

https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dags.html#airflowignore
A pattern can be negated by prefixing with !. Patterns are evaluated in order so a negation can override a previously defined pattern in the same file or patterns defined in a parent directory.

Taken from #58636:

.
├── dag.py
├── ignored.py
└── subdir/
  ├── dag.py
  └── ignored.py
# .airflowignore

*
!dag.py
!subdir/dag.py

With the above setup, only dag.py and subdir/dag.py are included. Files
like ignored.py and subdir/ignored.py and the rest stays ignored.

Previously, the * pattern would match and prune subdir before the negation
patterns could be evaluated.

The fix checks if any negation pattern exists in the rules. If a directory
would be ignored but there are negation patterns, the directory is not pruned,
allowing file-level matching to decide what gets included.

Closes: #58636


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@seruman seruman force-pushed the airflowignore-subfolder-negation branch from 8becebf to 5cbc956 Compare November 26, 2025 17:59
@henry3260
Copy link
Contributor

Hi @seruman , thanks for submitting this PR!

I was already assigned to this issue #58636 and have just pushed my own solution here: (#58740).

To avoid redundant work and merge conflicts, I recommend closing this PR so we can focus the review on mine. Feel free to leave any comments or suggestions on my PR if you spot anything! Thanks!

@seruman
Copy link
Author

seruman commented Nov 26, 2025

My bad, have not noticed it.

@seruman seruman closed this Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

airflowignore negation does not work in subfolders

2 participants