Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(observability): classify an unconfigured wallet as expected user-state

M3gA-Mind8351ecdd8462
diff --git a/src/core/observability.rs b/src/core/observability.rs
index c2bb5432ba..7f4d59a323 100644
--- a/src/core/observability.rs
+++ b/src/core/observability.rs
@@ -358,6 +358,32 @@ pub enum ExpectedErrorKind {
/// (`"MCP unauthorized for "` + `"(HTTP 401"`) so an unrelated MCP transport
/// failure still reaches Sentry.
McpServerNeedsAuth,
+ /// The wallet has not been set up yet, and something that needs a
+ /// wallet-derived key said so.
+ ///
+ /// A wallet is an **optional** feature. Not having one is the default
+ /// state for every user who has not opted in, the UI already renders a
+ /// "set up wallet" prompt, and there is no local lever that makes the call
+ /// succeed until the user creates one — so this is user-state, not a
+ /// defect.
+ ///
+ /// `jsonrpc.rs` already demoted the *bare* message via
+ /// `is_wallet_not_configured_error`, but that predicate is exact equality,
+ /// so it stops matching the moment any caller adds context — and callers
+ /// do: `format!("{context}: {e}")` appears ~800 times in `src/`. One such
+ /// wrap (`self_identity key_status: {e}`) was enough to route an
+ /// expected state to Sentry 55 times in 72 minutes on an ordinary local
+ /// session, while a genuine turn-killing failure in the same session
+ /// emitted nothing (#5805 / #5804).
+ ///
+ /// Classifying it **here** rather than at the wrap site is deliberate:
+ /// this classifier is substring-based, so it holds for any wrapper, at any
+ /// nesting depth, on any reporting path that goes through
+ /// [`report_error_or_expected`] — not just the RPC boundary, and not just
+ /// the one method that happened to be observed. Matched against the shared
+ /// [`crate::openhuman::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE`]
+ /// constant so producer and classifier cannot drift.
+ WalletNotConfigured,
/// The memory store refused a write because the caller-supplied
/// **namespace / key** failed a boundary check — it carries secret-shaped
/// text, or it trimmed to empty. The rejection is deterministic in the
@@ -448,6 +474,14 @@ pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {
if is_mcp_server_needs_auth_message(&lower) {
return Some(ExpectedErrorKind::McpServerNeedsAuth);
}
+ // #5805 — a wallet-derived key was needed and the user has no wallet. An
+ // optional feature nobody enabled is not a defect. Placed beside the other
+ // highly-specific anchors: the needle is a full sentence produced by one
+ // constant, so it cannot collide with the generic matchers below, and
+ // ordering here is for clarity rather than precedence.
+ if is_wallet_not_configured_message(&lower) {
+ return Some(ExpectedErrorKind::WalletNotConfigured);
+ }
// TAURI-RUST-QWW (#5164) — the memory store rejected a write because the
// caller's namespace/key failed a boundary check. Deterministic in the
// caller's input, so the same call retried fails identically and each retry
@@ -1103,6 +1137,22 @@ fn is_mcp_server_needs_auth_message(lower: &str) -> bool {
lower.contains("mcp unauthorized for ") && lower.contains("(http 401")
}
+/// Detect the wallet's "not set up yet" sentinel, anywhere in the message.
+///
+/// Substring rather than equality **on purpose**: the same condition arrives
+/// bare from a direct RPC and context-wrapped from any caller that does
+/// `format!("{context}: {e}")`. Both are the same user-state and both must be
+/// demoted, so the predicate must not care how many layers wrapped it.
+///
+/// The needle is the shared producer constant, not a copy, so a wording change
+/// moves both sides at once. `wallet_not_configured_sentinel_is_ascii_lowercase`
+/// pins the remaining assumption — that the constant is already lowercase, so
+/// it can be compared against the pre-lowercased haystack without allocating.
+/// See [`ExpectedErrorKind::WalletNotConfigured`].
+fn is_wallet_not_configured_message(lower: &str) -> bool {
+ lower.contains(crate::openhuman::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE)
+}
+
/// Detect a memory-store **identifier** rejection: the caller's namespace/key
/// (or episodic `session_id`/`role`) failed a write-boundary check.
///
@@ -2088,6 +2138,20 @@ fn report_expected_message(kind: ExpectedErrorKind, message: &str, domain: &str,
"[observability] {domain}.{operation} skipped expected MCP needs-auth (401) error: {message}"
);
}
+ ExpectedErrorKind::WalletNotConfigured => {
+ // The user has not set up a wallet. That is the default state of an
+ // optional feature, the UI already prompts for setup, and no
+ // core-side change makes the call succeed — so demote to info: the
+ // breadcrumb survives for correlation, no error event fires.
+ // See `ExpectedErrorKind::WalletNotConfigured` (#5805).
+ tracing::info!(
+ domain = domain,
+ operation = operation,
+ kind = "wallet_not_configured",
+ error = %message,
+ "[observability] {domain}.{operation} skipped expected wallet-not-configured error: {message}"
+ );
+ }
ExpectedErrorKind::MemoryIdentifierRejected => {
// The memory store refused a write whose namespace/key failed a
// boundary check (secret-shaped, or empty after trim). Deterministic
@@ -3813,6 +3877,82 @@ mod tests {
);
}
+ /// #5805 — an unconfigured wallet is the default state of an optional
+ /// feature, but every path that surfaced it reached Sentry as an error: 55
+ /// events in 72 minutes on one ordinary local session, while a genuine
+ /// turn-killing failure in the same session emitted zero (#5804).
+ ///
+ /// The bare message was already demoted at the RPC boundary by
+ /// `jsonrpc::is_wallet_not_configured_error`, which is exact equality — so
+ /// a single caller adding context defeated it. The observed wrap is
+ /// `self_identity key_status: {e}`, but nothing about the fix is specific
+ /// to that method: the classifier is substring-based, so it must hold for
+ /// any wrapper, at any nesting depth, on every path that reports through
+ /// `report_error_or_expected`. The cases below pin exactly that.
+ #[test]
+ fn classifies_wallet_not_configured_as_expected_however_it_is_wrapped() {
+ let sentinel = crate::openhuman::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE;
+ for msg in [
+ // Bare, as the wallet layer produces it.
+ sentinel.to_string(),
+ // The wrap that #5805 actually observed.
+ format!("self_identity key_status: {sentinel}"),
+ // Two layers — a wrapper wrapping a wrapper. Exact equality and a
+ // single-prefix strip both fail here; substring matching does not.
+ format!("orchestration.self_identity failed: self_identity key_status: {sentinel}"),
+ // A different domain entirely, to show the fix is not scoped to the
+ // one call site the issue was found through.
+ format!("tinyplace signal seed: {sentinel}"),
+ ] {
+ assert_eq!(
+ expected_error_kind(&msg),
+ Some(ExpectedErrorKind::WalletNotConfigured),
+ "must classify an unconfigured wallet as expected, however wrapped: {msg}"
+ );
+ }
+ // Full demotion path (classifier -> report arm) must not panic.
+ report_error_or_expected(
+ &format!("self_identity key_status: {sentinel}"),
+ "rpc",
+ "invoke_method",
+ &[],
+ );
+ }
+
+ /// The demotion must stay narrow: a real wallet fault still has to page.
+ /// The needle is a whole sentence, so merely mentioning a wallet — or
+ /// failing *after* one is configured — must not be swallowed.
+ #[test]
+ fn wallet_demotion_does_not_swallow_real_wallet_failures() {
+ for msg in [
+ "wallet keychain read failed: entry not found",
+ "no wallet account derived for chain 'solana'",
+ "wallet is not responding",
+ "failed to decrypt wallet mnemonic",
+ ] {
+ assert_ne!(
+ expected_error_kind(msg),
+ Some(ExpectedErrorKind::WalletNotConfigured),
+ "must NOT classify as WalletNotConfigured: {msg}"
+ );
+ }
+ }
+
+ /// `is_wallet_not_configured_message` compares the shared constant against
+ /// an already-lowercased haystack without allocating, which is only sound
+ /// while the constant itself is lowercase. If a future reword introduces a
+ /// capital, this fails here rather than silently ending the demotion.
+ #[test]
+ fn wallet_not_configured_sentinel_is_ascii_lowercase() {
+ let sentinel = crate::openhuman::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE;
+ assert_eq!(
+ sentinel,
+ sentinel.to_ascii_lowercase(),
+ "WALLET_NOT_CONFIGURED_MESSAGE must stay ASCII-lowercase, or \
+ is_wallet_not_configured_message must lowercase it before comparing"
+ );
+ }
+
/// Sentry TAURI-RUST-QWW (#5164): a memory-store identifier rejection is
/// deterministic in the caller's own input, so it repeats at the caller's
/// retry rate (3,055 events / 1 user / 1 day) without carrying new signal.
diff --git a/src/openhuman/web3/ops.rs b/src/openhuman/web3/ops.rs
index 6916fce27a..cae041593e 100644
--- a/src/openhuman/web3/ops.rs
+++ b/src/openhuman/web3/ops.rs
@@ -27,7 +27,7 @@ async fn wallet_address(family: ChainFamily) -> Result<String, String> {
};
let status = wallet::status().await?.value;
if !status.configured {
- return Err("wallet is not configured; run wallet setup first".to_string());
+ return Err(wallet::WALLET_NOT_CONFIGURED_MESSAGE.to_string());
}
status
.accounts
diff --git a/src/openhuman/web3/wallet/execution.rs b/src/openhuman/web3/wallet/execution.rs
index e0c102543b..30eba77355 100644
--- a/src/openhuman/web3/wallet/execution.rs
+++ b/src/openhuman/web3/wallet/execution.rs
@@ -25,7 +25,9 @@ use super::defaults::{
network_defaults as default_networks, rpc_url_for_chain, EvmNetwork, WalletAssetDefinition,
WalletNetworkDefaults,
};
-use super::ops::{status as wallet_status, WalletAccount, WalletChain};
+use super::ops::{
+ status as wallet_status, WalletAccount, WalletChain, WALLET_NOT_CONFIGURED_MESSAGE,
+};
const LOG_PREFIX: &str = "[wallet]";
const QUOTE_TTL_MS: u64 = 5 * 60 * 1000;
@@ -316,7 +318,7 @@ pub(crate) async fn require_evm_account() -> Result<String, String> {
async fn require_account(chain: WalletChain) -> Result<WalletAccount, String> {
let status = wallet_status().await?.value;
if !status.configured {
- return Err("wallet is not configured; run wallet setup first".to_string());
+ return Err(WALLET_NOT_CONFIGURED_MESSAGE.to_string());
}
status
.accounts
@@ -676,7 +678,7 @@ fn evm_native_asset(network: EvmNetwork) -> Result<WalletAssetDefinition, String
pub async fn balances() -> Result<RpcOutcome<Vec<BalanceInfo>>, String> {
let status = wallet_status().await?.value;
if !status.configured {
- return Err("wallet is not configured; run wallet setup first".to_string());
+ return Err(WALLET_NOT_CONFIGURED_MESSAGE.to_string());
}
let mut out = Vec::with_capacity(status.accounts.len() + EVM_BALANCE_NETWORKS.len());
for account in &status.accounts {