You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AirflowRuntimeVaryingValueChecker misses runtime-varying values in tasks after nested non-DAG with-statements #68796
When a non-DAG with-statement (e.g. with open(...) as f) is nested inside a DAG with-block, any tasks constructed AFTER that nested with — but still inside the DAG block — are silently missed by the DAG version inflation checker. datetime.now(), random(), uuid4() etc. in those tasks are never flagged.
To reproduce:
fromairflowimportDAGfromdatetimeimportdatetimefromairflow.operators.bashimportBashOperatorwithDAG('my_dag') asdag:
withopen('file.txt') asf: # non-DAG with-statementdata=f.read()
# datetime.now() here is NOT flagged — but it should bet1=BashOperator(task_id='t', bash_command=str(datetime.now()))
Root cause: visit_With() in dag_version_inflation_checker.py calls exit_dag_context() unconditionally at the end of every with-statement, even non-DAG ones. This resets is_in_dag_context=False, blinding the checker to subsequent tasks.
What you think should happen instead?
The BashOperator using datetime.now() should be flagged as a runtime-varying value causing DAG version inflation, because it is still inside the DAG with-block.
Activity