The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(mcp_setup): surface the status read-back failure instead of logging it away\n\nReview feedback on #6132: when `status()` itself fails, the old code logged a\nwarning, dropped the error with `.ok()`, and fell into the same "could not be\nread back" message a missing row produces. Two different facts — "the registry\ncould not be asked" and "the registry has no row for this server" — arrived as\none string, and the reason lived only in a log line no user sees.\n\n`classify_install_connect` now takes `Result<Option<&ConnStatus>, &str>` and\ndistinguishes all three inputs, carrying the underlying error into the message\nfor the `Err` arm.\n\nAlso records, at the `Ok(Some(..))` arm, why the synthetic fallback is not the\nusual path: `last_error` is the connect failure the registry recorded —\n`connections::connect` builds a `ConnectFailure` from the original error and\nstores it (`vendor/tinymcp/.../registry/connections/types.rs:195-212`), and\n`classify` surfaces it (`:507`). The synthetic message is reached only when a\nnon-connected server has no recorded failure at all.\n
M3gA-Mind919a8da6367c
diff --git a/src/openhuman/mcp/registry/setup_ops.rs b/src/openhuman/mcp/registry/setup_ops.rsindex 20c7369ab0..55d5132117 100644--- a/src/openhuman/mcp/registry/setup_ops.rs+++ b/src/openhuman/mcp/registry/setup_ops.rs@@ -226,10 +226,28 @@ pub async fn mcp_setup_test_connection(/// than assumed connected: the install is confirmed either way, and claiming a/// connection we did not observe is the failure mode this change exists to/// remove (#6110).-fn classify_install_connect(status: Option<&ConnStatus>) -> (&'static str, Option<String>) {+///+/// The three inputs are deliberately distinct, because they are three different+/// facts and a caller acts on them differently:+///+/// - `Ok(Some(entry))` — the registry answered and knows this server.+/// - `Ok(None)` — the registry answered but has no row for it.+/// - `Err(reason)` — the status query itself failed. The reason is carried into+/// the message rather than being left in a log line the user never sees:+/// "the registry could not be asked" is not the same fact as "the server is+/// not connected", and a transient store error must not read as the latter.+fn classify_install_connect(+ status: Result<Option<&ConnStatus>, &str>,+) -> (&'static str, Option<String>) {match status {- Some(entry) if matches!(entry.status, ServerStatus::Connected) => ("connected", None),- Some(entry) => (+ Ok(Some(entry)) if matches!(entry.status, ServerStatus::Connected) => ("connected", None),+ // `last_error` is the connect failure the registry recorded, not a+ // description of some later state: `connections::connect` builds a+ // `ConnectFailure` from the original error and stores it, and+ // `classify` surfaces it here. The synthetic arm below is reached only+ // when a non-connected server has no recorded failure at all (a+ // `Disabled` install, say), where naming the state is the whole answer.+ Ok(Some(entry)) => ("installed_disconnected",Some(entry.last_error.clone().unwrap_or_else(|| {format!(@@ -238,9 +256,15 @@ fn classify_install_connect(status: Option<&ConnStatus>) -> (&'static str, Optio)})),),- None => (+ Ok(None) => ("installed_disconnected",- Some("installed, but the server's connection state could not be read back".to_string()),+ Some("installed, but the registry reported no status row for this server".to_string()),+ ),+ Err(reason) => (+ "installed_disconnected",+ Some(format!(+ "installed, but the server's connection state could not be read back: {reason}"+ )),),}}@@ -287,19 +311,22 @@ pub async fn mcp_setup_install_and_connect(.map_err(|error| error.to_string())?;let server_id = outcome.server_id.clone();- let connection = host- .dynamic()- .status()- .await- .map_err(|error| {+ let connection = match host.dynamic().status().await {+ Ok(all) => Ok(all.into_iter().find(|entry| entry.server_id == server_id)),+ Err(error) => {log::warn!("[mcp_setup] install_and_connect could not read back status for \server_id={server_id}: {error}");- })- .ok()- .and_then(|all| all.into_iter().find(|entry| entry.server_id == server_id));- let (status, error) = classify_install_connect(connection.as_ref());+ Err(error.to_string())+ }+ };+ let (status, error) = classify_install_connect(+ connection+ .as_ref()+ .map(Option::as_ref)+ .map_err(String::as_str),+ );let connected = status == "connected";let tools = super::tools_safe_for_agent(&server_id, outcome.tools);diff --git a/src/openhuman/mcp/registry/setup_ops_tests.rs b/src/openhuman/mcp/registry/setup_ops_tests.rsindex 7a784f67ca..2ac204d70f 100644--- a/src/openhuman/mcp/registry/setup_ops_tests.rs+++ b/src/openhuman/mcp/registry/setup_ops_tests.rs@@ -73,7 +73,7 @@ fn conn_status(status: ServerStatus, last_error: Option<&str>) -> ConnStatus {fn a_connected_server_classifies_as_connected_with_no_error() {let entry = conn_status(ServerStatus::Connected, None);assert_eq!(- super::classify_install_connect(Some(&entry)),+ super::classify_install_connect(Ok(Some(&entry))),("connected", None));}@@ -85,13 +85,16 @@ fn a_connected_server_with_no_tools_is_still_connected() {// `connected` reads from `ServerStatus`, never from the tool count.let mut entry = conn_status(ServerStatus::Connected, None);entry.tool_count = 0;- assert_eq!(super::classify_install_connect(Some(&entry)).0, "connected");+ assert_eq!(+ super::classify_install_connect(Ok(Some(&entry))).0,+ "connected"+ );}#[test]fn a_failed_connect_reports_installed_disconnected_and_carries_the_reason() {let entry = conn_status(ServerStatus::Error, Some("dial tcp: connection refused"));- let (status, error) = super::classify_install_connect(Some(&entry));+ let (status, error) = super::classify_install_connect(Ok(Some(&entry)));assert_eq!(status, "installed_disconnected");assert_eq!(error.as_deref(), Some("dial tcp: connection refused"));}@@ -101,7 +104,7 @@ fn a_401_reports_installed_disconnected_rather_than_connected() {// `Unauthorized` is reachable, distinct from `Error`, and is emphatically// not connected — a caller offering a sign-in path needs to see that.let entry = conn_status(ServerStatus::Unauthorized, Some("server answered 401"));- let (status, error) = super::classify_install_connect(Some(&entry));+ let (status, error) = super::classify_install_connect(Ok(Some(&entry)));assert_eq!(status, "installed_disconnected");assert_eq!(error.as_deref(), Some("server answered 401"));}@@ -111,7 +114,7 @@ fn a_non_connected_status_without_a_reason_still_names_the_state() {// `last_error` is `Option`; the schema's `error` is documented as present// whenever `status != connected`, so it must not go missing here.let entry = conn_status(ServerStatus::Disconnected, None);- let (status, error) = super::classify_install_connect(Some(&entry));+ let (status, error) = super::classify_install_connect(Ok(Some(&entry)));assert_eq!(status, "installed_disconnected");assert!(error.as_deref().is_some_and(|e| e.contains("disconnected")),@@ -120,13 +123,36 @@ fn a_non_connected_status_without_a_reason_still_names_the_state() {}#[test]-fn an_unreadable_status_is_not_assumed_connected() {- let (status, error) = super::classify_install_connect(None);+fn a_missing_status_row_is_not_assumed_connected() {+ let (status, error) = super::classify_install_connect(Ok(None));assert_eq!(status, "installed_disconnected",- "a status we could not read back must never be reported as connected"+ "a server with no status row must never be reported as connected"+ );+ assert!(+ error+ .as_deref()+ .is_some_and(|e| e.contains("no status row")),+ "and it must say which of the two unknowns it hit, got: {error:?}"+ );+}++#[test]+fn a_failed_status_query_surfaces_its_own_reason() {+ // The status *method* failing is a different fact from the server being+ // disconnected, and the reason must reach the caller rather than only a+ // log line (tinysweeper on #6132).+ let (status, error) = super::classify_install_connect(Err("store is poisoned"));+ assert_eq!(status, "installed_disconnected");+ let error = error.expect("a failed read-back must carry a reason");+ assert!(+ error.contains("store is poisoned"),+ "the underlying error must be surfaced, not swallowed: {error}"+ );+ assert!(+ error.contains("could not be read back"),+ "and it must say the read-back is what failed: {error}");- assert!(error.is_some(), "and it must say why");}#[test]