Skip to content

Commit

Permalink
specialize errors for response encoding failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeoghegan committed Jan 16, 2024
1 parent b15270d commit bfca110
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ impl VdafOps {
report.public_share().to_vec(),
)
.get_encoded()
.map_err(|e| Arc::new(e.into()))?;
.map_err(|e| Arc::new(Error::ResponseEncode(e)))?;
let try_hpke_open = |hpke_keypair: &HpkeKeypair| {
hpke::open(
hpke_keypair,
Expand Down Expand Up @@ -1706,7 +1706,8 @@ impl VdafOps {
prepare_init.report_share().metadata().clone(),
prepare_init.report_share().public_share().to_vec(),
)
.get_encoded()?;
.get_encoded()
.map_err(Error::ResponseEncode)?;
let try_hpke_open = |hpke_keypair: &HpkeKeypair| {
hpke::open(
hpke_keypair,
Expand Down Expand Up @@ -2735,7 +2736,9 @@ impl VdafOps {
&Role::Leader,
&Role::Collector,
),
&leader_aggregate_share.get_encoded()?,
&leader_aggregate_share
.get_encoded()
.map_err(Error::ResponseEncode)?,
&AggregateShareAad::new(
*collection_job.task_id(),
collection_job.aggregation_parameter().get_encoded()?,
Expand All @@ -2754,7 +2757,8 @@ impl VdafOps {
encrypted_leader_aggregate_share,
encrypted_helper_aggregate_share.clone(),
)
.get_encoded()?,
.get_encoded()
.map_err(Error::ResponseEncode)?,
))
}
CollectionJobState::Abandoned => Err(Error::AbandonedCollectionJob(*collection_job_id)),
Expand Down Expand Up @@ -3079,13 +3083,20 @@ impl VdafOps {
let encrypted_aggregate_share = hpke::seal(
collector_hpke_config,
&HpkeApplicationInfo::new(&Label::AggregateShare, &Role::Helper, &Role::Collector),
&aggregate_share_job.helper_aggregate_share().get_encoded()?,
&aggregate_share_job
.helper_aggregate_share()
.get_encoded()
.map_err(Error::ResponseEncode)?,
&AggregateShareAad::new(
*task.id(),
aggregate_share_job.aggregation_parameter().get_encoded()?,
aggregate_share_job
.aggregation_parameter()
.get_encoded()
.map_err(Error::ResponseEncode)?,
aggregate_share_req.batch_selector().clone(),
)
.get_encoded()?,
.get_encoded()
.map_err(Error::ResponseEncode)?,
)?;

Ok(AggregateShare::new(encrypted_aggregate_share))
Expand Down Expand Up @@ -3155,7 +3166,7 @@ async fn send_request_to_helper<T: Encode>(
http_request_duration_histogram: &Histogram<f64>,
) -> Result<Bytes, Error> {
let domain = url.domain().unwrap_or_default().to_string();
let request_body = request.get_encoded()?;
let request_body = request.get_encoded().map_err(Error::ResponseEncode)?;
let (auth_header, auth_value) = auth_token.request_authentication();
let method_string = method.as_str().to_string();

Expand Down

0 comments on commit bfca110

Please sign in to comment.