Skip to content

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

fix(devices): drop pairing session when device persistence fails

Steven Enamakel7c641dbbcb8c
diff --git a/crates/openhuman-core/src/security/devices/bus.rs b/crates/openhuman-core/src/security/devices/bus.rs
index 5c422da9a7..c2d9a6d954 100644
--- a/crates/openhuman-core/src/security/devices/bus.rs
+++ b/crates/openhuman-core/src/security/devices/bus.rs
@@ -412,6 +412,7 @@ async fn handle_tunnel_frame(channel_id: &str, payload_b64: &str) {
"[devices/bus] failed to persist device channel_id={}: {e}",
channel_id
);
+ abandon_unpersisted_pairing(channel_id);
}
}
} else {
@@ -419,9 +420,20 @@ async fn handle_tunnel_frame(channel_id: &str, payload_b64: &str) {
"[devices/bus] could not load config to persist device channel_id={}",
channel_id
);
+ abandon_unpersisted_pairing(channel_id);
}
}
+/// Drops the pairing session and session cipher of a handshake whose device
+/// could not be persisted: with no row in the store, later frames would
+/// otherwise keep being accepted for a device nothing records
+/// (`super::owner` treats a missing row as the handshake persistence window).
+fn abandon_unpersisted_pairing(channel_id: &str) {
+ PENDING_SESSIONS.lock().unwrap().remove(channel_id);
+ ACTIVE_CIPHERS.lock().unwrap().remove(channel_id);
+ log::warn!("[devices/bus] pairing abandoned channel_id={channel_id}: device not persisted");
+}
+
fn parse_handshake_payload(raw: &str) -> HandshakePayload {
let trimmed = raw.trim();
match serde_json::from_str::<JsonHandshakePayload>(trimmed) {