You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kalluripradeep (via GitHub)" <gi...@apache.org> on 2026/06/21 09:52:57 UTC
[PR] fix: nested non-DAG with-statement prematurely exits DAG context in version inflation checker [airflow]
kalluripradeep opened a new pull request, #68795:
URL: https://github.com/apache/airflow/pull/68795
## What's the problem?
`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 reset `is_in_dag_context=False`. Any tasks constructed **after** the nested `with` — but still inside the DAG block — were invisible to the checker and never flagged for runtime-varying values even when they used `datetime.now()`, `random()`, etc.
```python
with DAG('my_dag') as dag:
with open('file.txt') as f: # <-- this incorrectly exited DAG context
data = f.read()
# BUG: this task was NOT detected as inside the DAG — datetime.now() not flagged
t1 = BashOperator(task_id='t', bash_command=str(datetime.now()))
```
## Root cause
```python
# visit_With (before fix) — line 517
self.dag_detector.exit_dag_context() # unconditional, wrong
```
## Fix
Guard the call with `if is_with_dag_context` so only the `with`-statement that actually entered the DAG context exits it.
```python
if is_with_dag_context:
self.dag_detector.exit_dag_context()
```
## Changes
- `airflow-core/src/airflow/utils/dag_version_inflation_checker.py` — one-line guard
- `airflow-core/tests/unit/utils/test_dag_version_inflation_checker.py` — 4 regression tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: nested non-DAG with-statement prematurely exits DAG context in version inflation checker [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #68795:
URL: https://github.com/apache/airflow/pull/68795#issuecomment-5260476618
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: nested non-DAG with-statement prematurely exits DAG context in version inflation checker [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #68795: fix: nested non-DAG with-statement prematurely exits DAG context in version inflation checker
URL: https://github.com/apache/airflow/pull/68795
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix nested non-Dag with-statement exiting the Dag context in version inflation checker [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #68795:
URL: https://github.com/apache/airflow/pull/68795#issuecomment-5372082972
### Backport successfully created: v3-3-test
Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>✅</td>
<td>v3-3-test</td>
<td><a href="https://github.com/apache/airflow/pull/71956"><img src="https://img.shields.io/badge/PR-71956-blue" alt="PR Link"></a></td>
</tr>
</table>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix nested non-Dag with-statement exiting the Dag context in version inflation checker [airflow]
Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham merged PR #68795:
URL: https://github.com/apache/airflow/pull/68795
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org