fix(dag-processing): don't drop import errors when no listener is reg…#69845
fix(dag-processing): don't drop import errors when no listener is reg…#69845kjh0623 wants to merge 2 commits into
Conversation
…istered _update_import_errors() eagerly evaluated ParseImportError.full_file_path() to build the on_new/on_existing_dag_import_error listener arguments, even when no listener was registered. full_file_path() instantiates the DAG bundle via DagBundlesManager().get_bundle(), which for some bundle types (e.g. the Git bundle) resolves an Airflow Connection. Performing that work inside the DAG-parsing transaction can disturb it and roll back the not-yet-flushed ParseImportError row, so the DAG ends up flagged as broken (has_import_errors) while no import error is ever shown in the UI. Guard both listener notifications with get_listener_manager().has_listeners so full_file_path() is only resolved when a listener is actually registered. This fixes the silent drop in the common (no-listener) case and avoids the wasted bundle instantiation on every import error. Signed-off-by: kjh0623 <8412070+kjh0623@users.noreply.github.com>
|
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
|
Signed-off-by: kjh0623 <8412070+kjh0623@users.noreply.github.com>
|
Had a look through this and the guard reads right to me. |
|
Thanks for the review! |
|
Thanks for fixing the no-listener case. I think there may still be a similar transaction issue when any listener plugin is registered.
For bundle types like the Git bundle, calling Would it be reasonable to pass the already-known As a side benefit, the existing-error path would no longer need the extra I tried this approach locally with a registered listener for both new and existing import errors, and the listener still received the expected filename while the |
…istered
_update_import_errors() eagerly evaluated ParseImportError.full_file_path() to build the on_new/on_existing_dag_import_error listener arguments, even when no listener was registered. full_file_path() instantiates the DAG bundle via DagBundlesManager().get_bundle(), which for some bundle types (e.g. the Git bundle) resolves an Airflow Connection. Performing that work inside the DAG-parsing transaction can disturb it and roll back the not-yet-flushed ParseImportError row, so the DAG ends up flagged as broken (has_import_errors) while no import error is ever shown in the UI.
Guard both listener notifications with get_listener_manager().has_listeners so full_file_path() is only resolved when a listener is actually registered. This fixes the silent drop in the common (no-listener) case and avoids the wasted bundle instantiation on every import error.
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.