Skip to content

[v3-3-test] Fix nested non-Dag with-statement exiting the Dag context in version inflation checker (#68795) - #71956

Merged
jedcunningham merged 1 commit into
v3-3-testfrom
backport-c1fcbef-v3-3-test
Aug 25, 2026
Merged

jedcunningham merged 1 commit into
v3-3-testfrom
backport-c1fcbef-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

AirflowRuntimeVaryingValueChecker.visit_With() called exit_dag_context()
unconditionally at the end of every with-statement. When a non-DAG
with-statement (e.g. with open(...) as f) was nested inside a DAG
with-block, it would set is_in_dag_context=False, causing any tasks
constructed AFTER the nested with — but still inside the DAG block —
to be invisible to the checker. Those tasks were never flagged for
runtime-varying values even when they used datetime.now(), random(), etc.

Fix: guard the exit_dag_context() call with if is_with_dag_context
so only the with-statement that actually entered the DAG context exits it.

Regression tests added for:

  • nested non-DAG with followed by a task (primary case)
  • multiple successive nested non-DAG withs
  • task constructed inside a nested non-DAG with
  • task outside the DAG block not over-flagged after the fix
    (cherry picked from commit c1fcbef)

Co-authored-by: Pradeep Kalluri 128097794+kalluripradeep@users.noreply.github.com

… in version inflation checker (#68795)

AirflowRuntimeVaryingValueChecker.visit_With() called exit_dag_context()
unconditionally at the end of every with-statement. When a non-DAG
with-statement (e.g. `with open(...) as f`) was nested inside a DAG
with-block, it would set is_in_dag_context=False, causing any tasks
constructed AFTER the nested with — but still inside the DAG block —
to be invisible to the checker. Those tasks were never flagged for
runtime-varying values even when they used datetime.now(), random(), etc.

Fix: guard the exit_dag_context() call with `if is_with_dag_context`
so only the with-statement that actually entered the DAG context exits it.

Regression tests added for:
- nested non-DAG with followed by a task (primary case)
- multiple successive nested non-DAG withs
- task constructed inside a nested non-DAG with
- task outside the DAG block not over-flagged after the fix
(cherry picked from commit c1fcbef)

Co-authored-by: Pradeep Kalluri <128097794+kalluripradeep@users.noreply.github.com>
@jedcunningham
jedcunningham marked this pull request as ready for review August 24, 2026 13:53
@jedcunningham
jedcunningham merged commit 8e6ce12 into v3-3-test Aug 25, 2026
300 of 344 checks passed
@jedcunningham
jedcunningham deleted the backport-c1fcbef-v3-3-test branch August 25, 2026 16:43
@github-actions github-actions Bot added this to the Airflow 3.3.2 milestone Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.2 based on: bug fix merged to version branch
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

vatsrahul1001 pushed a commit that referenced this pull request Sep 7, 2026
… in version inflation checker (#68795) (#71956)

AirflowRuntimeVaryingValueChecker.visit_With() called exit_dag_context()
unconditionally at the end of every with-statement. When a non-DAG
with-statement (e.g. `with open(...) as f`) was nested inside a DAG
with-block, it would set is_in_dag_context=False, causing any tasks
constructed AFTER the nested with — but still inside the DAG block —
to be invisible to the checker. Those tasks were never flagged for
runtime-varying values even when they used datetime.now(), random(), etc.

Fix: guard the exit_dag_context() call with `if is_with_dag_context`
so only the with-statement that actually entered the DAG context exits it.

Regression tests added for:
- nested non-DAG with followed by a task (primary case)
- multiple successive nested non-DAG withs
- task constructed inside a nested non-DAG with
- task outside the DAG block not over-flagged after the fix
(cherry picked from commit c1fcbef)

Co-authored-by: Pradeep Kalluri <128097794+kalluripradeep@users.noreply.github.com>
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants