From 0d0e404f99f6f94f423ea1820c1bdfbd8b535994 Mon Sep 17 00:00:00 2001 From: Kartik Date: Tue, 19 Nov 2024 12:34:38 +0530 Subject: [PATCH] fix: properly parsing numbers that are strings --- crates/frontend/src/components/context_form/utils.rs | 11 ++++++++++- crates/frontend/src/utils.rs | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/frontend/src/components/context_form/utils.rs b/crates/frontend/src/components/context_form/utils.rs index 6d0a1c76..bc11c421 100644 --- a/crates/frontend/src/components/context_form/utils.rs +++ b/crates/frontend/src/components/context_form/utils.rs @@ -7,6 +7,7 @@ use crate::{ }, }; use anyhow::Result; +use leptos::logging; use serde_json::{json, Map, Value}; pub fn get_condition_schema( @@ -186,7 +187,15 @@ pub fn construct_context( } else { let condition_schemas = conditions .iter() - .map(|condition| get_condition_schema(condition, dimensions.clone()).unwrap()) + .map( + |condition| match get_condition_schema(condition, dimensions.clone()) { + Ok(ans) => ans, + Err(err) => { + logging::log!("Error while getting condition schema {:?}", err); + Value::Null + } + }, + ) .collect::>(); if condition_schemas.len() == 1 { diff --git a/crates/frontend/src/utils.rs b/crates/frontend/src/utils.rs index 8e061676..72a8ff6a 100644 --- a/crates/frontend/src/utils.rs +++ b/crates/frontend/src/utils.rs @@ -313,6 +313,8 @@ pub fn parse_value(val: &Value, config_type: ConfigValueType) -> Result match val { Value::String(_) => Ok(val.clone()), + Value::Number(i) => Ok(Value::String(i.to_string())), + Value::Bool(b) => Ok(Value::String(b.to_string())), Value::Array(arr) => { if arr.iter().all(|item| item.is_string()) { Ok(val.clone())