From e4c1b4edcd390bcc294d49c32af62c2b5aaeb5aa Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Thu, 5 Dec 2024 15:51:19 +0100 Subject: [PATCH 1/2] no-status-code-passthrough --- agenta-cli/agenta/sdk/decorators/routing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agenta-cli/agenta/sdk/decorators/routing.py b/agenta-cli/agenta/sdk/decorators/routing.py index 32b0d29bfb..ae5ccd7f78 100644 --- a/agenta-cli/agenta/sdk/decorators/routing.py +++ b/agenta-cli/agenta/sdk/decorators/routing.py @@ -394,7 +394,7 @@ def handle_failure(self, error: Exception): log.warning(format_exc().strip("\n")) log.warning("--------------------------------------------------") - status_code = error.status_code if hasattr(error, "status_code") else 500 + status_code = 500 message = str(error) stacktrace = format_exception(error, value=error, tb=error.__traceback__) # type: ignore detail = {"message": message, "stacktrace": stacktrace} From 9d856ca69486295b4e0042a64ada65250d6d3c60 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Thu, 5 Dec 2024 15:56:40 +0100 Subject: [PATCH 2/2] handle errors in callVariant --- agenta-web/src/services/api.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/agenta-web/src/services/api.ts b/agenta-web/src/services/api.ts index 93bdd70a0d..4031e76103 100644 --- a/agenta-web/src/services/api.ts +++ b/agenta-web/src/services/api.ts @@ -151,7 +151,11 @@ export async function callVariant( return response }) .catch(async (error) => { - console.log("Unsecure call to LLM App failed:", error?.status) + console.log("Unsecure call to LLM App failed:", error) + + if (error?.response?.status !== 401) { + throw error + } let response = await axios .post(secure_url, requestBody, { @@ -163,7 +167,9 @@ export async function callVariant( return response }) .catch((error) => { - console.log("Secure call to LLM App failed:", error?.status) + console.log("Secure call to LLM App failed:", error) + + throw error }) return response @@ -200,7 +206,11 @@ export const fetchVariantParametersFromOpenAPI = async ( return response }) .catch(async (error) => { - console.log("Unsecure call to LLM App failed:", error?.status) + console.log("Unsecure call to LLM App failed:", error) + + if (error?.response?.status !== 401) { + throw error + } let response = await axios .get(secure_url, { @@ -211,7 +221,9 @@ export const fetchVariantParametersFromOpenAPI = async ( return response }) .catch((error) => { - console.log("Secure call to LLM App failed:", error?.status) + console.log("Secure call to LLM App failed:", error) + + throw error }) return response