fix: ExternalTaskSensor check_existence ignored in deferrable mode (Airflow < 3.0)#64394
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
|
Hello, I do not think there will be another provider release for airflow 2.x, if this does occur airflow 3, and it is a broader issue than just this sensor, a new rpc for the supervisor might be worth it |
|
The check is encapsulated in the else block of "if AIRFLOW_V_3_0_PLUS", so it should not affect versions >=3.0. If the new rpc seems to be a reasonable new implementation, then I'll start working on it. Otherwise, deprecating this flag for higher versions would be an option, as it doesn't seem that impactful to have it. |
Looks good, just add a test case and I think it's fine, when airflow 2 reaches end of life it can be removed, if you can also (in a different PR) fix it for airflow 3, it would be appreciated Some of the failing tests are due to celery and unrelated, can be ignored for now, but I did not look at all of the checks |
providers/standard/src/airflow/providers/standard/sensors/external_task.py
Show resolved
Hide resolved
providers/standard/tests/unit/standard/sensors/test_external_task_sensor.py
Outdated
Show resolved
Hide resolved
…ption Co-authored-by: Wei Lee <weilee.rx@gmail.com>
providers/standard/src/airflow/providers/standard/sensors/external_task.py
Show resolved
Hide resolved
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Root cause
In execute(), the deferrable path calls self.defer() directly without first calling _check_for_existence.
Fix
For Airflow < 3.0, call _check_for_existence inside a scoped create_session block before running self.defer() if check_existence flag is set to True.
This fix only works for versions below 3.0 since there is no direct way to assert DAG existence on higher versions. One possible solution would be creating a new RPC call to try to retrieve a specific DAG, but I'm not sure on creating it just for this reason.
closes: #40745
Was generative AI tooling used to co-author this PR?