refactor: surface silent fallbacks with eprintln! logging

Add eprintln! logging before fallback values in 7 files where errors
were previously swallowed without visibility:

- [stream] malformed JSON chunk, missing usage tokens, missing tool call index
- [mcp] missing result fields, client builder failure, response body read error
- [subagent] missing API key in settings, all resolution paths exhausted
- [state] memory_dir no-parent, session_id missing, lock poisoned, store_base_dir
- [input] missing default_model for provider
- [session] corrupt agents.json parse failure
- [pkce] clock-before-epoch on random byte generation

All fallback values are preserved — this adds observability without
changing behavior for callers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
asepharyana
2026-07-12 10:50:34 +07:00
co-authored by Claude Opus 4.8
parent bb621fdff2
commit e29dfadaa7
7 changed files with 97 additions and 25 deletions
+4 -1
View File
@@ -8,7 +8,10 @@ pub fn load_session_agents(session_dir: &Path) -> Vec<AgentDefinition> {
}
match std::fs::read_to_string(&agents_file) {
Ok(content) => {
serde_json::from_str(&content).unwrap_or_default()
serde_json::from_str(&content).unwrap_or_else(|e| {
eprintln!("[session] failed to parse agents.json: {}", e);
Vec::new()
})
}
Err(_) => Vec::new(),
}