Skip to content

Commit 83b8572

Browse files
fix(desktop): log an aggregate kept/skipped count on lenient directory parse
Review follow-up on #3866: per-entry warns identify which profile is malformed, but spotting a poisoned directory shouldn't require counting them — emit one aggregate kept/skipped line per query when anything was dropped. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Bryce Del Rio <[email protected]>
1 parent 7dc1272 commit 83b8572

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎desktop/src-tauri/src/commands/agent_discovery.rs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ fn parse_relay_agents(agents: serde_json::Value) -> Vec<RelayAgentInfo> {
10831083
let serde_json::Value::Array(items) = agents else {
10841084
return Vec::new();
10851085
};
1086-
items
1086+
let total = items.len();
1087+
let parsed: Vec<RelayAgentInfo> = items
10871088
.into_iter()
10881089
.filter_map(|item| {
10891090
let pubkey_hint = item
@@ -1101,7 +1102,17 @@ fn parse_relay_agents(agents: serde_json::Value) -> Vec<RelayAgentInfo> {
11011102
}
11021103
}
11031104
})
1104-
.collect()
1105+
.collect();
1106+
// One aggregate line per query so a poisoned directory is visible at a
1107+
// glance without counting per-entry warns.
1108+
let skipped = total - parsed.len();
1109+
if skipped > 0 {
1110+
tracing::warn!(
1111+
"list_relay_agents: kept {kept} of {total} agent profiles, skipped {skipped} unparseable",
1112+
kept = parsed.len()
1113+
);
1114+
}
1115+
parsed
11051116
}
11061117

11071118
#[cfg(test)]

0 commit comments

Comments
 (0)