feat: enhance error handling in OAuth URL building and client creation; improve tool argument sanitization
This commit is contained in:
+10
-1
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user