@@ -5,11 +5,10 @@ use crate::cryptography::backup_pke::{self, BackupCiphertext};
55use crate :: cryptography:: internal_crypto_types:: PrivateSigKey ;
66use crate :: engine:: context:: ContextInfo ;
77use crate :: engine:: threshold:: service:: ThresholdFheKeys ;
8+ use crate :: engine:: validation:: { parse_optional_proto_request_id, RequestIdParsingErr } ;
89use crate :: vault:: Vault ;
910use crate :: {
10- engine:: {
11- base:: BaseKmsStruct , threshold:: traits:: ContextManager , validation:: validate_request_id,
12- } ,
11+ engine:: { base:: BaseKmsStruct , threshold:: traits:: ContextManager } ,
1312 grpc:: metastore_status_service:: CustodianMetaStore ,
1413 vault:: storage:: { crypto_material:: ThresholdCryptoMaterialStorage , Storage } ,
1514} ;
@@ -147,15 +146,10 @@ where
147146 PrivS : Storage + Sync + Send + ' static ,
148147{
149148 async fn inner_new_custodian_context ( & self , context : CustodianContext ) -> anyhow:: Result < ( ) > {
150- let context_id: RequestId = match context. context_id {
151- Some ( id) => id. into ( ) ,
152- None => {
153- return Err ( anyhow:: anyhow!(
154- "Context ID is required in NewCustodianContextRequest"
155- ) )
156- }
157- } ;
158- validate_request_id ( & context_id) ?;
149+ let context_id: RequestId = parse_optional_proto_request_id (
150+ & context. context_id ,
151+ RequestIdParsingErr :: CustodianContext ,
152+ ) ?;
159153 let backup_vault = match self . crypto_storage . inner . backup_vault {
160154 Some ( ref backup_vault) => backup_vault,
161155 None => return Err ( anyhow:: anyhow!( "Backup vault is not configured" ) ) ,
@@ -177,7 +171,10 @@ where
177171 let custodian_context = InternalCustodianContext {
178172 context_id,
179173 threshold : context. threshold ,
180- previous_context_id : context. previous_context_id . map ( Into :: into) ,
174+ previous_context_id : Some ( parse_optional_proto_request_id (
175+ & context. previous_context_id ,
176+ RequestIdParsingErr :: CustodianContext ,
177+ ) ?) ,
181178 custodian_nodes : node_map,
182179 backup_enc_key : backup_enc_key. clone ( ) ,
183180 } ;
0 commit comments