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
@@ -27,7 +27,10 @@ fn rand_byte() -> u8 {
use std::time::{SystemTime, UNIX_EPOCH};
let nanos = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.unwrap_or_else(|_| {
eprintln!("[pkce] system time before UNIX_EPOCH, using 0 for random byte");
std::time::Duration::default()
})
.subsec_nanos();
(nanos & 0xFF) as u8
}