From a4419c440069b29a02de2e320247803f964bd69b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 3 Feb 2026 19:32:56 -0800 Subject: [PATCH] fix: fix linting errors --- .../custom_code/CustomCodePlayground.tsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ui/litellm-dashboard/src/components/guardrails/custom_code/CustomCodePlayground.tsx b/ui/litellm-dashboard/src/components/guardrails/custom_code/CustomCodePlayground.tsx index 7d45a77a5c8..307c76c01df 100644 --- a/ui/litellm-dashboard/src/components/guardrails/custom_code/CustomCodePlayground.tsx +++ b/ui/litellm-dashboard/src/components/guardrails/custom_code/CustomCodePlayground.tsx @@ -110,22 +110,29 @@ const CustomCodePlayground: React.FC = ({ throw new Error("Invalid JSON in request data"); } - const result = await testCustomCodeGuardrail( - accessToken, - customCode, - parsedInputs, - parsedRequestData, - inputType - ); + const response = await testCustomCodeGuardrail(accessToken, { + custom_code: customCode, + test_input: parsedInputs, + input_type: inputType, + request_data: parsedRequestData, + }); - setTestResult(result); + if (response.success && response.result) { + setTestResult(response.result); - if (result.action === "allow") { - NotificationsManager.success("Guardrail allowed the request"); - } else if (result.action === "block") { - NotificationsManager.fromBackend(`Guardrail blocked: ${result.reason || "No reason provided"}`); - } else if (result.action === "modify") { - NotificationsManager.success("Guardrail modified the content"); + if (response.result.action === "allow") { + NotificationsManager.success("Guardrail allowed the request"); + } else if (response.result.action === "block") { + NotificationsManager.fromBackend(`Guardrail blocked: ${response.result.reason || "No reason provided"}`); + } else if (response.result.action === "modify") { + NotificationsManager.success("Guardrail modified the content"); + } + } else if (response.error) { + setTestResult({ + action: "block", + error: response.error, + }); + NotificationsManager.fromBackend(`Test failed: ${response.error}`); } } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error";