From 9c83c8a396deea7fb52429202e39cf7849df25eb Mon Sep 17 00:00:00 2001 From: TakayukiTanabe Date: Mon, 6 Jan 2025 16:20:33 +0900 Subject: [PATCH] fix for review --- providers/src/airflow/providers/http/exceptions.py | 3 +++ providers/src/airflow/providers/http/hooks/http.py | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/providers/src/airflow/providers/http/exceptions.py b/providers/src/airflow/providers/http/exceptions.py index 57c440a691113..1f20b5249e109 100644 --- a/providers/src/airflow/providers/http/exceptions.py +++ b/providers/src/airflow/providers/http/exceptions.py @@ -18,5 +18,8 @@ from airflow.exceptions import AirflowException +class HttpErrorException(AirflowException): + """Exception raised for HTTP error in Http hook.""" + class HttpMethodException(AirflowException): """Exception raised for invalid HTTP methods in Http hook.""" diff --git a/providers/src/airflow/providers/http/hooks/http.py b/providers/src/airflow/providers/http/hooks/http.py index 1afd1396874cd..76c192c7a6e18 100644 --- a/providers/src/airflow/providers/http/hooks/http.py +++ b/providers/src/airflow/providers/http/hooks/http.py @@ -32,7 +32,7 @@ from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook -from airflow.providers.http.exceptions import HttpMethodException +from airflow.providers.http.exceptions import HttpErrorException, HttpMethodException if TYPE_CHECKING: from aiohttp.client_reqrep import ClientResponse @@ -452,9 +452,7 @@ async def run( self.log.exception("HTTP error with status: %s", e.status) # In this case, the user probably made a mistake. # Don't retry. - raise AirflowException(f"{e.status}:{e.message}") - else: - await asyncio.sleep(self.retry_delay) + raise HttpErrorException(f"{e.status}:{e.message}") else: return response