From 1936377eea8a32c01711de2e4036a6aeb9aecb69 Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 6 Aug 2024 16:15:38 +0800 Subject: [PATCH 1/2] fix: direct return response if tracer id is null Signed-off-by: FogDong --- src/bentoml/_internal/cloud/client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bentoml/_internal/cloud/client.py b/src/bentoml/_internal/cloud/client.py index 6fa6777469e..e73c9d3785b 100644 --- a/src/bentoml/_internal/cloud/client.py +++ b/src/bentoml/_internal/cloud/client.py @@ -76,9 +76,15 @@ def _is_not_found(self, resp: httpx.Response) -> bool: def _check_resp(self, resp: httpx.Response) -> None: if resp.status_code >= 500: - raise CloudRESTApiClientError( - f"Oops, something went wrong with BentoCloud. Please report to us with trace ID <{resp.headers['x-trace-id']}>: https://bentoml.com/support" - ) + if 'x-trace-id' in resp.headers: + raise CloudRESTApiClientError( + f"Oops, something went wrong with BentoCloud. Please report to us with trace ID <{resp.headers['x-trace-id']}>: https://bentoml.com/support" + ) + else: + raise CloudRESTApiClientError( + f"request failed with status code {resp.status_code}: {resp.text}", + error_code=resp.status_code, + ) if resp.status_code != 200: raise CloudRESTApiClientError( f"request failed with status code {resp.status_code}: {resp.text}", From 7a26d91733864bcf141e57212daabfe0cdb13e7f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 08:16:12 +0000 Subject: [PATCH 2/2] ci: auto fixes from pre-commit.ci For more information, see https://pre-commit.ci --- src/bentoml/_internal/cloud/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bentoml/_internal/cloud/client.py b/src/bentoml/_internal/cloud/client.py index e73c9d3785b..d4d45e33558 100644 --- a/src/bentoml/_internal/cloud/client.py +++ b/src/bentoml/_internal/cloud/client.py @@ -76,7 +76,7 @@ def _is_not_found(self, resp: httpx.Response) -> bool: def _check_resp(self, resp: httpx.Response) -> None: if resp.status_code >= 500: - if 'x-trace-id' in resp.headers: + if "x-trace-id" in resp.headers: raise CloudRESTApiClientError( f"Oops, something went wrong with BentoCloud. Please report to us with trace ID <{resp.headers['x-trace-id']}>: https://bentoml.com/support" )