From 877a63c15c7201b0cbe4b80533a4d42a88a4d6f7 Mon Sep 17 00:00:00 2001 From: ashrafchowdury Date: Tue, 30 Jul 2024 21:47:03 +0600 Subject: [PATCH] fix: fixed human evaluation tests syntax error --- agenta-web/src/lib/helpers/utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/agenta-web/src/lib/helpers/utils.ts b/agenta-web/src/lib/helpers/utils.ts index 3bb410c09b..63e6168504 100644 --- a/agenta-web/src/lib/helpers/utils.ts +++ b/agenta-web/src/lib/helpers/utils.ts @@ -122,10 +122,15 @@ export const removeKeys = (obj: GenericObject, keys: string[]) => { export const safeParse = (str: string, fallback: any = "") => { try { - return JSON.parse(str) + if (!str) return fallback + + if (typeof str !== "string") { + return JSON.parse(str) + } else { + return str + } } catch (error) { console.log("error parsing JSON:", error) - console.log("fallbacking to:", fallback) return fallback } }