Skip to content

Commit

Permalink
Merge branch 'replace_panic_with_error_in_get_root_subnet_id' into 'm…
Browse files Browse the repository at this point in the history
…aster'

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

Allows for more error tolerant handling of registry entries upstream. 

See merge request dfinity-lab/public/ic!12843
  • Loading branch information
stiegerc committed Jun 13, 2023
2 parents 220cbce + 7bdc2e6 commit 4cad19b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rs/registry/helpers/src/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ impl<T: RegistryClient + ?Sized> SubnetRegistry for T {
let bytes = self.get_value(ROOT_SUBNET_ID_KEY, version);
Ok(deserialize_registry_value::<SubnetIdProto>(bytes)?
.and_then(|subnet_id_proto| subnet_id_proto.principal_id)
.map(|pr_id| PrincipalId::try_from(pr_id.raw).expect("Could not parse principal id!"))
.map(|pr_id| {
PrincipalId::try_from(pr_id.raw).map_err(|err| DecodeError {
error: format!("get_root_subnet_id() failed with {}", err),
})
})
.transpose()?
.map(SubnetId::from))
}

Expand Down

0 comments on commit 4cad19b

Please sign in to comment.