Skip to content

Commit

Permalink
Merge branch 'replace_panic_with_error_in_get_routing_table' into 'ma…
Browse files Browse the repository at this point in the history
…ster'

Removes the panic from `get_routing_table()` and returns an error instead.

Allows for more error tolerant handling of registry entries upstream. 

See merge request dfinity-lab/public/ic!12846
  • Loading branch information
stiegerc committed Jun 13, 2023
2 parents 4183d7d + 0d8fef4 commit 5eede20
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rs/registry/helpers/src/routing_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ic_interfaces_registry::{RegistryClient, RegistryClientResult};
use ic_protobuf::registry::routing_table::v1 as pb;
use ic_registry_keys::{make_canister_migrations_record_key, make_routing_table_record_key};
use ic_registry_routing_table::{CanisterIdRange, CanisterMigrations, RoutingTable};
use ic_types::{RegistryVersion, SubnetId};
use ic_types::{registry::RegistryClientError::DecodeError, RegistryVersion, SubnetId};
use std::convert::TryFrom;

/// A trait that allows access to `RoutingTable`. The expectation for the
Expand All @@ -27,8 +27,13 @@ impl<T: RegistryClient + ?Sized> RoutingTableRegistry for T {
let bytes = self.get_value(&make_routing_table_record_key(), version);
deserialize_registry_value::<pb::RoutingTable>(bytes).map(|option_pb_routing_table| {
option_pb_routing_table
.map(|pb_routing_table| RoutingTable::try_from(pb_routing_table).unwrap())
})
.map(|pb_routing_table| {
RoutingTable::try_from(pb_routing_table).map_err(|err| DecodeError {
error: format!("get_routing_table() failed with {}", err),
})
})
.transpose()
})?
}

fn get_subnet_canister_ranges(
Expand Down

0 comments on commit 5eede20

Please sign in to comment.