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
+13 -4
View File
@@ -60,10 +60,19 @@ impl AppConfig {
pub fn load() -> Self {
let store = super::store::Store::new();
let path = store.base_dir.join("app_config.json");
let mut cfg: AppConfig = std::fs::read_to_string(path)
.ok()
.and_then(|s| serde_json::from_str(&s).ok())
.unwrap_or_default();
let mut cfg: AppConfig = match std::fs::read_to_string(&path) {
Ok(s) => match serde_json::from_str(&s) {
Ok(c) => c,
Err(e) => {
eprintln!(
"warning: failed to parse config file '{}': {}. Loading defaults.",
path.display(), e
);
Self::default()
}
},
Err(_) => Self::default(),
};
// Merge any default providers not present in the loaded config
let defaults = Self::default();
for (name, provider) in defaults.providers {
+3
View File
@@ -32,6 +32,9 @@ impl SessionLock {
}
fn is_alive(&self, pid: u32) -> bool {
// SAFETY: `libc::kill(pid, 0)` does not send a signal; it only checks
// whether the process exists and the caller has permission to signal
// it. The integer argument is a PID already validated by `try_lock`.
unsafe { libc::kill(pid as i32, 0) == 0 }
}
}