Repository navigation
Stop ExternalTaskSensor waiting for missing Dags on Airflow 3.2+ - #72517
Open
ignacioparicio wants to merge 2 commits into
Open
ignacioparicio wants to merge 2 commits into
ignacioparicio wants to merge 2 commits into
Conversation
Collaborator
|
closes: #72514 |
This was referenced Sep 10, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExternalTaskSensor(check_existence=True)is supposed to fail immediately when the external Dag does not exist. On Airflow 3 it does not check at all. Whenexternal_dag_idrefers to a Dag that does not exist, the sensor waits until its timeout instead of reporting the problem immediately.The same thing happens when waiting is handed off to the triggerer (
deferrable=True): the wait starts without a check.Note:
check_existence=True.Where it happens
In
providers/standard/src/airflow/providers/standard/sensors/external_task.py:_has_checked_existenceis meant to stop the same check from being repeated. In the Airflow 3 code it is set before any check has happened.The check itself is behind this condition:
Both copies of the condition are in Airflow 2-only code, so Airflow 3 never calls
_check_for_existence.How it got here
The existing check reads the metadata database and the Dag file. An Airflow 3 worker has access to neither, so it cannot use that implementation.
ExternalTaskSensorwork with Task SDK #48651 (6775bf7bae) split the sensor into Airflow 2 and Airflow 3 implementations. The status checks were moved to the new Airflow 3 implementation, but the existence check was not.ce88001bb2) later fixedcheck_existencewhendeferrable=True, but only for Airflow 2. The Airflow 3 code still starts waiting without checking.The missing piece was a way for a worker to ask whether a Dag exists. #56955 added that to the execution API in Airflow 3.2.
#67832 explored a broader check for individual tasks and task groups. It was closed because the answer depends on the Dag version used by a particular run. This PR does not add a new API. It uses the existing Dag lookup only to answer whether the external Dag itself exists.
What this PR does:
external_task.py: on Airflow 3.2 and later, asks the execution API whether the external Dag exists before the sensor starts waiting. A missing Dag raisesExternalDagNotFoundError; other API errors are left unchanged.external_task.py: applies the check whether the sensor waits itself or hands the wait to the triggerer, and documents the limits below.test_external_task_sensor.py: covers both ways of waiting, repeated checks, unexpected API errors, and older Airflow 3 versions.What this PR does not fix:
external_task_idsandexternal_task_group_idare still not checked. The external Dag is checked, but the execution API cannot say whether a task exists in the Dag version used by a particular run. When an external task or task group is configured, the sensor now warns that only the external Dag was checked. The full task and task-group check is not part of this PR.related: #72514
Was generative AI tooling used to co-author this PR?
Used to trace the regression through the history above, check what an Airflow 3 worker can ask the execution API, and review the implementation and tests.