From a0cf3d306de2fb3bc84d5e5c62ffd9aa45f6b48e Mon Sep 17 00:00:00 2001 From: Kacy Fortner Date: Sun, 8 Feb 2026 15:47:31 -0500 Subject: [PATCH] fix: replace unwrap() on map lookups in migration manager replace .unwrap() with .ok_or(MigrationError::NoMigrationInProgress) in start_import() and start_migrate(). while logically safe (the key was just inserted), a distributed system should handle state inconsistencies gracefully rather than crashing. --- crates/ember-cluster/src/migration.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ember-cluster/src/migration.rs b/crates/ember-cluster/src/migration.rs index dc221668..8449ce95 100644 --- a/crates/ember-cluster/src/migration.rs +++ b/crates/ember-cluster/src/migration.rs @@ -222,7 +222,9 @@ impl MigrationManager { let migration = Migration::new_importing(slot, source, local_id); self.incoming.insert(slot, migration); self.pending_keys.insert(slot, HashSet::new()); - Ok(self.incoming.get(&slot).unwrap()) + self.incoming + .get(&slot) + .ok_or(MigrationError::NoMigrationInProgress { slot }) } /// Start migrating a slot to another node. @@ -244,7 +246,9 @@ impl MigrationManager { let migration = Migration::new_migrating(slot, local_id, target); self.outgoing.insert(slot, migration); self.pending_keys.insert(slot, HashSet::new()); - Ok(self.outgoing.get(&slot).unwrap()) + self.outgoing + .get(&slot) + .ok_or(MigrationError::NoMigrationInProgress { slot }) } /// Record that a key has been migrated.