This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new dafc960643a improve exception handling in AzureDataFactoryTrigger
(#56350)
dafc960643a is described below
commit dafc960643a94c1b1eacd70e6353a05436cda698
Author: Cedrik Neumann <[email protected]>
AuthorDate: Mon Oct 13 17:31:29 2025 -0600
improve exception handling in AzureDataFactoryTrigger (#56350)
* fix: don't wrap exception in AirflowException
Wrapping the exception AirflowException serves no real purpose and
obscures the original exception for downstream handling.
* fix: do log the actual exception in the trigger
Although the exception text is passed back to the operator, we lose the
stack trace while doing so. By logging the exception in the trigger first,
we will get full details about where the exception happened.
* fix: don't override original exception when cancelling ADF pipeline run
When we fail to cancel a pipeline run after an unexpected error, we are
overriding the actual exception which caused the failure in first place.
This change addresses this by keeping the original exception untouched
and instead log any exception that occurs during the cancellation attempt.
* Update
providers/microsoft/azure/src/airflow/providers/microsoft/azure/triggers/data_factory.py
Co-authored-by: Ash Berlin-Taylor <[email protected]>
* refactor: remove unused exception
---------
Co-authored-by: Ash Berlin-Taylor <[email protected]>
---
.../src/airflow/providers/microsoft/azure/hooks/data_factory.py | 5 +----
.../src/airflow/providers/microsoft/azure/triggers/data_factory.py | 7 ++++---
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/data_factory.py
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/data_factory.py
index c49b066ea26..fc0d23c6a93 100644
---
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/data_factory.py
+++
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/data_factory.py
@@ -1214,7 +1214,4 @@ class AzureDataFactoryAsyncHook(AzureDataFactoryHook):
:param config: Extra parameters for the ADF client.
"""
client = await self.get_async_conn()
- try:
- await client.pipeline_runs.cancel(resource_group_name,
factory_name, run_id)
- except Exception as e:
- raise AirflowException(e)
+ await client.pipeline_runs.cancel(resource_group_name, factory_name,
run_id)
diff --git
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/triggers/data_factory.py
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/triggers/data_factory.py
index 5e275a66762..f047fe23241 100644
---
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/triggers/data_factory.py
+++
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/triggers/data_factory.py
@@ -229,14 +229,15 @@ class AzureDataFactoryTrigger(BaseTrigger):
}
)
except Exception as e:
+ self.log.exception(e)
if self.run_id:
try:
+ self.log.info("Cancelling pipeline run %s", self.run_id)
await hook.cancel_pipeline_run(
run_id=self.run_id,
resource_group_name=self.resource_group_name,
factory_name=self.factory_name,
)
- self.log.info("Unexpected error %s caught. Cancel pipeline
run %s", e, self.run_id)
- except Exception as err:
- yield TriggerEvent({"status": "error", "message":
str(err), "run_id": self.run_id})
+ except Exception:
+ self.log.exception("Failed to cancel pipeline run %s",
self.run_id)
yield TriggerEvent({"status": "error", "message": str(e),
"run_id": self.run_id})