Skip to content

The agent that grows with you

fix(cli): never let the snapshot rejoin replace the restore result

kshitijk4poor441c88290ed2
diff --git a/hermes_cli/cli_snapshot.py b/hermes_cli/cli_snapshot.py
index 21239ced4fe..d73e2f8c011 100644
--- a/hermes_cli/cli_snapshot.py
+++ b/hermes_cli/cli_snapshot.py
@@ -115,8 +115,13 @@ def _restore_gateway_snapshot(cli, store, snap_id):
"The host retries on its next rescan (within 30s).")
store.snapshots.clear()
store.current = None
- store.connection = GatewayConnection.shared()
- _rejoin_cli(cli, store)
+ # The restore's own result or error decides the reply; a failed rejoin must not replace it.
+ try:
+ store.connection = GatewayConnection.shared()
+ _rejoin_cli(cli, store)
+ except Exception as exc:
+ logger.warning("Rejoin after snapshot restore failed: %s", exc, exc_info=True)
+ print(f" Reconnecting to the gateway failed: {exc}. Run /new or restart the CLI.")
def _rejoin_cli(cli, store):