feat: enhance error handling in OAuth URL building and client creation; improve tool argument sanitization

This commit is contained in:
asepharyana
2026-07-12 10:23:26 +07:00
parent 0cc60c12ce
commit bb621fdff2
10 changed files with 79 additions and 43 deletions
+10 -1
View File
@@ -18,7 +18,16 @@ pub struct ToolFunction {
pub fn sanitize_tool_arguments(args: &Value) -> Value {
match args {
Value::String(s) => {
serde_json::from_str(s).unwrap_or_else(|_| args.clone())
match serde_json::from_str::<Value>(s) {
Ok(v) => v,
Err(e) => {
eprintln!(
"warning: tool argument is a JSON string but failed to parse: {}. Using raw string.",
e
);
args.clone()
}
}
}
obj @ Value::Object(_) => obj.clone(),
other => other.clone(),