From 8ce3d7c3145a5f81241bc7d74107114dc611c8ee Mon Sep 17 00:00:00 2001 From: Tim Geoghegan Date: Tue, 29 Aug 2023 14:14:57 -0700 Subject: [PATCH] Adopt DAP-05 error types DAP-05 changes a few error types. `unrecongizedMessage -> invalidMessage` `queryMismatch` is gone (now we use `invalidMessage` in that case) `roundMismatch -> stepMismatch` We still use the word "round" in several places where "step" would be more appropriate given DAP-05 text. Renaming those variables, etc., will arrive in a later commit to avoid adding unnecessary noise here. Part of #1669 --- aggregator/src/aggregator.rs | 90 +++++++++++++------ .../src/aggregator/aggregate_init_tests.rs | 51 ++++++++++- .../aggregator/aggregation_job_continue.rs | 14 +-- .../src/aggregator/aggregation_job_driver.rs | 9 +- aggregator/src/aggregator/error.rs | 22 ++--- aggregator/src/aggregator/http_handlers.rs | 32 +++---- aggregator/src/aggregator/problem_details.rs | 6 +- aggregator/src/aggregator/taskprov_tests.rs | 4 +- client/src/lib.rs | 4 +- collector/src/lib.rs | 12 +-- messages/src/lib.rs | 2 +- messages/src/problem_type.rs | 22 ++--- 12 files changed, 173 insertions(+), 95 deletions(-) diff --git a/aggregator/src/aggregator.rs b/aggregator/src/aggregator.rs index 879ad9d03..274f99299 100644 --- a/aggregator/src/aggregator.rs +++ b/aggregator/src/aggregator.rs @@ -290,9 +290,9 @@ impl Aggregator { Some(task_id_base64) => { let task_id_bytes = URL_SAFE_NO_PAD .decode(task_id_base64) - .map_err(|_| Error::UnrecognizedMessage(None, "task_id"))?; + .map_err(|_| Error::InvalidMessage(None, "task_id"))?; let task_id = TaskId::get_decoded(&task_id_bytes) - .map_err(|_| Error::UnrecognizedMessage(None, "task_id"))?; + .map_err(|_| Error::InvalidMessage(None, "task_id"))?; let task_aggregator = self .task_aggregator_for(&task_id) .await? @@ -734,7 +734,7 @@ impl Aggregator { .map(|url| url.try_into()) .collect::, _>>()?; if aggregator_urls.len() != 2 { - return Err(Error::UnrecognizedMessage( + return Err(Error::InvalidMessage( Some(*task_id), "taskprov configuration is missing one or both aggregators", )); @@ -1586,11 +1586,11 @@ impl VdafOps { let req = AggregationJobInitializeReq::::get_decoded(req_bytes)?; // If two ReportShare messages have the same report ID, then the helper MUST abort with - // error "unrecognizedMessage". (§4.4.4.1) + // error "invalidMessage". (§4.5.1.2) let mut seen_report_ids = HashSet::with_capacity(req.prepare_inits().len()); for prepare_init in req.prepare_inits() { if !seen_report_ids.insert(*prepare_init.report_share().metadata().id()) { - return Err(Error::UnrecognizedMessage( + return Err(Error::InvalidMessage( Some(*task.id()), "aggregate request contains duplicate report IDs", )); @@ -1700,37 +1700,71 @@ impl VdafOps { }); let plaintext_input_share = plaintext.and_then(|plaintext| { - let plaintext_input_share = PlaintextInputShare::get_decoded(&plaintext).map_err(|error| { - info!(task_id = %task.id(), metadata = ?prepare_init.report_share().metadata(), ?error, "Couldn't decode helper's plaintext input share"); - aggregate_step_failure_counter.add(1, &[KeyValue::new("type", "plaintext_input_share_decode_failure")]); - PrepareError::UnrecognizedMessage - })?; + let plaintext_input_share = + PlaintextInputShare::get_decoded(&plaintext).map_err(|error| { + info!( + task_id = %task.id(), + metadata = ?prepare_init.report_share().metadata(), + ?error, "Couldn't decode helper's plaintext input share", + ); + aggregate_step_failure_counter.add( + 1, + &[KeyValue::new( + "type", + "plaintext_input_share_decode_failure", + )], + ); + PrepareError::InvalidMessage + })?; // Check for repeated extensions. let mut extension_types = HashSet::new(); if !plaintext_input_share .extensions() .iter() - .all(|extension| extension_types.insert(extension.extension_type())) { - info!(task_id = %task.id(), metadata = ?prepare_init.report_share().metadata(), "Received report share with duplicate extensions"); - aggregate_step_failure_counter.add(1, &[KeyValue::new("type", "duplicate_extension")]); - return Err(PrepareError::UnrecognizedMessage) + .all(|extension| extension_types.insert(extension.extension_type())) + { + info!( + task_id = %task.id(), + metadata = ?prepare_init.report_share().metadata(), + "Received report share with duplicate extensions", + ); + aggregate_step_failure_counter + .add(1, &[KeyValue::new("type", "duplicate_extension")]); + return Err(PrepareError::InvalidMessage); } Ok(plaintext_input_share) }); let input_share = plaintext_input_share.and_then(|plaintext_input_share| { - A::InputShare::get_decoded_with_param(&(vdaf, Role::Helper.index().unwrap()), plaintext_input_share.payload()) - .map_err(|error| { - info!(task_id = %task.id(), metadata = ?prepare_init.report_share().metadata(), ?error, "Couldn't decode helper's input share"); - aggregate_step_failure_counter.add(1, &[KeyValue::new("type", "input_share_decode_failure")]); - PrepareError::UnrecognizedMessage - }) + A::InputShare::get_decoded_with_param( + &(vdaf, Role::Helper.index().unwrap()), + plaintext_input_share.payload(), + ) + .map_err(|error| { + info!( + task_id = %task.id(), + metadata = ?prepare_init.report_share().metadata(), + ?error, "Couldn't decode helper's input share", + ); + aggregate_step_failure_counter + .add(1, &[KeyValue::new("type", "input_share_decode_failure")]); + PrepareError::InvalidMessage + }) }); - let public_share = A::PublicShare::get_decoded_with_param(vdaf, prepare_init.report_share().public_share()).map_err(|error|{ - info!(task_id = %task.id(), metadata = ?prepare_init.report_share().metadata(), ?error, "Couldn't decode public share"); - aggregate_step_failure_counter.add(1, &[KeyValue::new("type", "public_share_decode_failure")]); - PrepareError::UnrecognizedMessage + let public_share = A::PublicShare::get_decoded_with_param( + vdaf, + prepare_init.report_share().public_share(), + ) + .map_err(|error| { + info!( + task_id = %task.id(), + metadata = ?prepare_init.report_share().metadata(), + ?error, "Couldn't decode public share", + ); + aggregate_step_failure_counter + .add(1, &[KeyValue::new("type", "public_share_decode_failure")]); + PrepareError::InvalidMessage }); let shares = input_share.and_then(|input_share| Ok((public_share?, input_share))); @@ -2035,7 +2069,7 @@ impl VdafOps { A::OutputShare: Send + Sync, { if leader_aggregation_job.round() == AggregationJobRound::from(0) { - return Err(Error::UnrecognizedMessage( + return Err(Error::InvalidMessage( Some(*task.id()), "aggregation job cannot be advanced to round 0", )); @@ -2113,11 +2147,11 @@ impl VdafOps { // If this is not a replay, the leader should be advancing our state to the next // round and no further. return Err(datastore::Error::User( - Error::RoundMismatch { + Error::StepMismatch { task_id: *task.id(), aggregation_job_id, - expected_round: helper_aggregation_job.round().increment(), - got_round: leader_aggregation_job.round(), + expected_step: helper_aggregation_job.round().increment(), + got_step: leader_aggregation_job.round(), } .into(), )); diff --git a/aggregator/src/aggregator/aggregate_init_tests.rs b/aggregator/src/aggregator/aggregate_init_tests.rs index 303263e41..aa9936d60 100644 --- a/aggregator/src/aggregator/aggregate_init_tests.rs +++ b/aggregator/src/aggregator/aggregate_init_tests.rs @@ -1,9 +1,13 @@ use crate::aggregator::{ - http_handlers::{aggregator_handler, test_util::decode_response_body}, + http_handlers::{ + aggregator_handler, + test_util::{decode_response_body, take_problem_details}, + }, tests::generate_helper_report_share, Config, }; use assert_matches::assert_matches; +use http::StatusCode; use janus_aggregator_core::{ datastore::{ test_util::{ephemeral_datastore, EphemeralDatastore}, @@ -31,6 +35,7 @@ use prio::{ }, }; use rand::random; +use serde_json::json; use std::sync::Arc; use trillium::{Handler, KnownHeaderName, Status}; use trillium_testing::{prelude::put, TestConn}; @@ -459,6 +464,48 @@ async fn aggregation_job_init_two_round_vdaf_idempotence() { let aggregation_job_resp: AggregationJobResp = decode_response_body(&mut response).await; assert_eq!( aggregation_job_resp, - test_case.aggregation_job_init_resp.unwrap() + test_case.aggregation_job_init_resp.unwrap(), + ); +} + +#[tokio::test] +async fn aggregation_job_init_wrong_query() { + let test_case = setup_aggregate_init_test().await; + + // setup_aggregate_init_test sets up a task with a time interval query. We send a fixed size + // query which should yield an error. + let wrong_query = AggregationJobInitializeReq::new( + test_case.aggregation_param.get_encoded(), + PartialBatchSelector::new_fixed_size(random()), + test_case.prepare_inits, + ); + + let mut response = put(test_case + .task + .aggregation_job_uri(&random()) + .unwrap() + .path()) + .with_request_header( + DAP_AUTH_HEADER, + test_case + .task + .primary_aggregator_auth_token() + .as_ref() + .to_owned(), + ) + .with_request_header( + KnownHeaderName::ContentType, + AggregationJobInitializeReq::::MEDIA_TYPE, + ) + .with_request_body(wrong_query.get_encoded()) + .run_async(&test_case.handler) + .await; + assert_eq!( + take_problem_details(&mut response).await, + json!({ + "status": StatusCode::BAD_REQUEST.as_u16(), + "type": "urn:ietf:params:ppm:dap:error:invalidMessage", + "title": "The message type for a response was incorrect or the payload was malformed.", + }), ); } diff --git a/aggregator/src/aggregator/aggregation_job_continue.rs b/aggregator/src/aggregator/aggregation_job_continue.rs index 0b7e5c3b9..6a8fc4c41 100644 --- a/aggregator/src/aggregator/aggregation_job_continue.rs +++ b/aggregator/src/aggregator/aggregation_job_continue.rs @@ -62,7 +62,7 @@ impl VdafOps { let report_aggregation = loop { let report_agg = report_aggregations_iter.next().ok_or_else(|| { datastore::Error::User( - Error::UnrecognizedMessage( + Error::InvalidMessage( Some(*task.id()), "leader sent unexpected, duplicate, or out-of-order prepare steps", ) @@ -116,7 +116,7 @@ impl VdafOps { } _ => { return Err(datastore::Error::User( - Error::UnrecognizedMessage( + Error::InvalidMessage( Some(*task.id()), "leader sent prepare step for non-WAITING report aggregation", ) @@ -597,7 +597,7 @@ mod tests { &round_zero_request, &test_case.handler, Status::BadRequest, - "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "urn:ietf:params:ppm:dap:error:invalidMessage", "The message type for a response was incorrect or the payload was malformed.", ) .await; @@ -768,8 +768,8 @@ mod tests { &past_round_request, &test_case.handler, Status::BadRequest, - "urn:ietf:params:ppm:dap:error:roundMismatch", - "The leader and helper are not on the same round of VDAF preparation.", + "urn:ietf:params:ppm:dap:error:stepMismatch", + "The leader and helper are not on the same step of VDAF preparation.", ) .await; } @@ -791,8 +791,8 @@ mod tests { &future_round_request, &test_case.handler, Status::BadRequest, - "urn:ietf:params:ppm:dap:error:roundMismatch", - "The leader and helper are not on the same round of VDAF preparation.", + "urn:ietf:params:ppm:dap:error:stepMismatch", + "The leader and helper are not on the same step of VDAF preparation.", ) .await; } diff --git a/aggregator/src/aggregator/aggregation_job_driver.rs b/aggregator/src/aggregator/aggregation_job_driver.rs index 3034add63..2b2d7609a 100644 --- a/aggregator/src/aggregator/aggregation_job_driver.rs +++ b/aggregator/src/aggregator/aggregation_job_driver.rs @@ -351,9 +351,10 @@ impl AggregationJobDriver { info!(report_id = %report_aggregation.report_id(), "Received report with duplicate extensions"); self.aggregate_step_failure_counter .add(1, &[KeyValue::new("type", "duplicate_extension")]); - report_aggregations_to_write.push(report_aggregation.with_state( - ReportAggregationState::Failed(PrepareError::UnrecognizedMessage), - )); + report_aggregations_to_write.push( + report_aggregation + .with_state(ReportAggregationState::Failed(PrepareError::InvalidMessage)), + ); continue; } @@ -1515,7 +1516,7 @@ mod tests { *repeated_extension_report.metadata().time(), 1, None, - ReportAggregationState::Failed(PrepareError::UnrecognizedMessage), + ReportAggregationState::Failed(PrepareError::InvalidMessage), ); let want_missing_report_report_aggregation = ReportAggregation::::new( diff --git a/aggregator/src/aggregator/error.rs b/aggregator/src/aggregator/error.rs index 524e74d08..c9c265282 100644 --- a/aggregator/src/aggregator/error.rs +++ b/aggregator/src/aggregator/error.rs @@ -31,19 +31,19 @@ pub enum Error { /// far in the future, §4.3.2. #[error("task {0}: report {1} too early: {2}")] ReportTooEarly(TaskId, ReportId, Time), - /// Corresponds to `unrecognizedMessage`, §3.2 - #[error("task {0:?}: unrecognized message: {1}")] - UnrecognizedMessage(Option, &'static str), - /// Corresponds to `roundMismatch` + /// Corresponds to `invalidMessage`, §3.2 + #[error("task {0:?}: invalid message: {1}")] + InvalidMessage(Option, &'static str), + /// Corresponds to `stepMismatch` #[error( - "task {task_id}: unexpected round in aggregation job {aggregation_job_id} (expected \ - {expected_round}, got {got_round})" + "task {task_id}: unexpected step in aggregation job {aggregation_job_id} (expected \ + {expected_step}, got {got_step})" )] - RoundMismatch { + StepMismatch { task_id: TaskId, aggregation_job_id: AggregationJobId, - expected_round: AggregationJobRound, - got_round: AggregationJobRound, + expected_step: AggregationJobRound, + got_step: AggregationJobRound, }, /// Corresponds to `unrecognizedTask`, §3.2 #[error("task {0}: unrecognized task")] @@ -157,8 +157,8 @@ impl Error { Error::Message(_) => "message", Error::ReportRejected(_, _, _) => "report_rejected", Error::ReportTooEarly(_, _, _) => "report_too_early", - Error::UnrecognizedMessage(_, _) => "unrecognized_message", - Error::RoundMismatch { .. } => "round_mismatch", + Error::InvalidMessage(_, _) => "unrecognized_message", + Error::StepMismatch { .. } => "step_mismatch", Error::UnrecognizedTask(_) => "unrecognized_task", Error::MissingTaskId => "missing_task_id", Error::UnrecognizedAggregationJob(_, _) => "unrecognized_aggregation_job", diff --git a/aggregator/src/aggregator/http_handlers.rs b/aggregator/src/aggregator/http_handlers.rs index b3ee890bf..b06804457 100644 --- a/aggregator/src/aggregator/http_handlers.rs +++ b/aggregator/src/aggregator/http_handlers.rs @@ -44,16 +44,16 @@ impl Handler for Error { match self { Error::InvalidConfiguration(_) => conn.with_status(Status::InternalServerError), Error::MessageDecode(_) => { - conn.with_problem_details(DapProblemType::UnrecognizedMessage, None) + conn.with_problem_details(DapProblemType::InvalidMessage, None) } Error::ReportRejected(task_id, _, _) => { conn.with_problem_details(DapProblemType::ReportRejected, Some(task_id)) } - Error::UnrecognizedMessage(task_id, _) => { - conn.with_problem_details(DapProblemType::UnrecognizedMessage, task_id.as_ref()) + Error::InvalidMessage(task_id, _) => { + conn.with_problem_details(DapProblemType::InvalidMessage, task_id.as_ref()) } - Error::RoundMismatch { task_id, .. } => { - conn.with_problem_details(DapProblemType::RoundMismatch, Some(task_id)) + Error::StepMismatch { task_id, .. } => { + conn.with_problem_details(DapProblemType::StepMismatch, Some(task_id)) } Error::UnrecognizedTask(task_id) => { conn.with_problem_details(DapProblemType::UnrecognizedTask, Some(task_id)) @@ -99,7 +99,7 @@ impl Handler for Error { | Error::TaskParameters(_) => conn.with_status(Status::InternalServerError), Error::AggregateShareRequestRejected(_, _) => conn.with_status(Status::BadRequest), Error::EmptyAggregation(task_id) => { - conn.with_problem_details(DapProblemType::UnrecognizedMessage, Some(task_id)) + conn.with_problem_details(DapProblemType::InvalidMessage, Some(task_id)) } Error::ForbiddenMutation { .. } => conn.with_status(Status::Conflict), Error::BadRequest(_) => conn.with_status(Status::BadRequest), @@ -582,14 +582,14 @@ fn parse_taskprov_header( Some(taskprov_header) => { let task_config_encoded = &URL_SAFE_NO_PAD.decode(taskprov_header).map_err(|_| { - Error::UnrecognizedMessage( + Error::InvalidMessage( Some(*task_id), "taskprov header could not be decoded", ) })?; if task_id.as_ref() != digest(&SHA256, task_config_encoded).as_ref() { - Err(Error::UnrecognizedMessage( + Err(Error::InvalidMessage( Some(*task_id), "derived taskprov task ID does not match task config", )) @@ -1842,7 +1842,7 @@ mod tests { ); assert_matches!( prepare_step_2.result(), - &PrepareStepResult::Reject(PrepareError::UnrecognizedMessage) + &PrepareStepResult::Reject(PrepareError::InvalidMessage) ); let prepare_step_3 = aggregate_resp.prepare_resps().get(3).unwrap(); @@ -1882,7 +1882,7 @@ mod tests { ); assert_eq!( prepare_step_6.result(), - &PrepareStepResult::Reject(PrepareError::UnrecognizedMessage), + &PrepareStepResult::Reject(PrepareError::InvalidMessage), ); let prepare_step_7 = aggregate_resp.prepare_resps().get(7).unwrap(); @@ -1892,7 +1892,7 @@ mod tests { ); assert_eq!( prepare_step_7.result(), - &PrepareStepResult::Reject(PrepareError::UnrecognizedMessage), + &PrepareStepResult::Reject(PrepareError::InvalidMessage), ); let prepare_step_8 = aggregate_resp.prepare_resps().get(8).unwrap(); @@ -2382,7 +2382,7 @@ mod tests { take_problem_details(&mut test_conn).await, json!({ "status": want_status, - "type": "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "type": "urn:ietf:params:ppm:dap:error:invalidMessage", "title": "The message type for a response was incorrect or the payload was malformed.", "taskid": format!("{}", task.id()), }) @@ -3778,7 +3778,7 @@ mod tests { &request, &handler, Status::BadRequest, - "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "urn:ietf:params:ppm:dap:error:invalidMessage", "The message type for a response was incorrect or the payload was malformed.", ) .await; @@ -3950,7 +3950,7 @@ mod tests { &request, &handler, Status::BadRequest, - "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "urn:ietf:params:ppm:dap:error:invalidMessage", "The message type for a response was incorrect or the payload was malformed.", ) .await; @@ -4036,7 +4036,7 @@ mod tests { &request, &handler, Status::BadRequest, - "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "urn:ietf:params:ppm:dap:error:invalidMessage", "The message type for a response was incorrect or the payload was malformed.", ) .await; @@ -4135,7 +4135,7 @@ mod tests { take_problem_details(&mut test_conn).await, json!({ "status": Status::BadRequest as u16, - "type": "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "type": "urn:ietf:params:ppm:dap:error:invalidMessage", "title": "The message type for a response was incorrect or the payload was malformed.", }) ); diff --git a/aggregator/src/aggregator/problem_details.rs b/aggregator/src/aggregator/problem_details.rs index 03c95e04a..64476aec5 100644 --- a/aggregator/src/aggregator/problem_details.rs +++ b/aggregator/src/aggregator/problem_details.rs @@ -81,7 +81,7 @@ mod tests { #[test] fn dap_problem_type_round_trip() { for problem_type in [ - DapProblemType::UnrecognizedMessage, + DapProblemType::InvalidMessage, DapProblemType::UnrecognizedTask, DapProblemType::MissingTaskId, DapProblemType::UnrecognizedAggregationJob, @@ -135,8 +135,8 @@ mod tests { Some(DapProblemType::ReportRejected), ), TestCase::new( - Box::new(|| Error::UnrecognizedMessage(Some(random()), "test")), - Some(DapProblemType::UnrecognizedMessage), + Box::new(|| Error::InvalidMessage(Some(random()), "test")), + Some(DapProblemType::InvalidMessage), ), TestCase::new( Box::new(|| Error::UnrecognizedTask(random())), diff --git a/aggregator/src/aggregator/taskprov_tests.rs b/aggregator/src/aggregator/taskprov_tests.rs index 9ce14b4d2..b6d22d0d1 100644 --- a/aggregator/src/aggregator/taskprov_tests.rs +++ b/aggregator/src/aggregator/taskprov_tests.rs @@ -467,7 +467,7 @@ async fn taskprov_opt_out_mismatched_task_id() { take_problem_details(&mut test_conn).await, json!({ "status": Status::BadRequest as u16, - "type": "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "type": "urn:ietf:params:ppm:dap:error:invalidMessage", "title": "The message type for a response was incorrect or the payload was malformed.", "taskid": format!("{}", test.task_id), }) @@ -548,7 +548,7 @@ async fn taskprov_opt_out_missing_aggregator() { take_problem_details(&mut test_conn).await, json!({ "status": Status::BadRequest as u16, - "type": "urn:ietf:params:ppm:dap:error:unrecognizedMessage", + "type": "urn:ietf:params:ppm:dap:error:invalidMessage", "title": "The message type for a response was incorrect or the payload was malformed.", "taskid": format!("{}", another_task_id), }) diff --git a/client/src/lib.rs b/client/src/lib.rs index eb508a5be..49ca5caac 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -422,7 +422,7 @@ mod tests { .with_status(400) .with_header("Content-Type", "application/problem+json") .with_body(concat!( - "{\"type\": \"urn:ietf:params:ppm:dap:error:unrecognizedMessage\", ", + "{\"type\": \"urn:ietf:params:ppm:dap:error:invalidMessage\", ", "\"detail\": \"The message type for a response was incorrect or the payload was \ malformed.\"}", )) @@ -436,7 +436,7 @@ mod tests { assert_eq!(problem.status.unwrap(), StatusCode::BAD_REQUEST); assert_eq!( problem.type_url.unwrap(), - "urn:ietf:params:ppm:dap:error:unrecognizedMessage" + "urn:ietf:params:ppm:dap:error:invalidMessage" ); assert_eq!( problem.detail.unwrap(), diff --git a/collector/src/lib.rs b/collector/src/lib.rs index 3d2df9f3e..9e4028f76 100644 --- a/collector/src/lib.rs +++ b/collector/src/lib.rs @@ -1326,7 +1326,7 @@ mod tests { .with_status(400) .with_header("Content-Type", "application/problem+json") .with_body(concat!( - "{\"type\": \"urn:ietf:params:ppm:dap:error:unrecognizedMessage\", ", + "{\"type\": \"urn:ietf:params:ppm:dap:error:invalidMessage\", ", "\"detail\": \"The message type for a response was incorrect or the payload was \ malformed.\"}" )) @@ -1340,9 +1340,9 @@ mod tests { .unwrap_err(); assert_matches!(error, Error::Http { problem_details, dap_problem_type } => { assert_eq!(problem_details.status.unwrap(), StatusCode::BAD_REQUEST); - assert_eq!(problem_details.type_url.unwrap(), "urn:ietf:params:ppm:dap:error:unrecognizedMessage"); + assert_eq!(problem_details.type_url.unwrap(), "urn:ietf:params:ppm:dap:error:invalidMessage"); assert_eq!(problem_details.detail.unwrap(), "The message type for a response was incorrect or the payload was malformed."); - assert_eq!(dap_problem_type, Some(DapProblemType::UnrecognizedMessage)); + assert_eq!(dap_problem_type, Some(DapProblemType::InvalidMessage)); }); mock_bad_request.assert_async().await; @@ -1420,7 +1420,7 @@ mod tests { .with_status(400) .with_header("Content-Type", "application/problem+json") .with_body(concat!( - "{\"type\": \"urn:ietf:params:ppm:dap:error:unrecognizedMessage\", ", + "{\"type\": \"urn:ietf:params:ppm:dap:error:invalidMessage\", ", "\"detail\": \"The message type for a response was incorrect or the payload was \ malformed.\"}" )) @@ -1431,9 +1431,9 @@ mod tests { let error = collector.poll_once(&job).await.unwrap_err(); assert_matches!(error, Error::Http { problem_details, dap_problem_type } => { assert_eq!(problem_details.status.unwrap(), StatusCode::BAD_REQUEST); - assert_eq!(problem_details.type_url.unwrap(), "urn:ietf:params:ppm:dap:error:unrecognizedMessage"); + assert_eq!(problem_details.type_url.unwrap(), "urn:ietf:params:ppm:dap:error:invalidMessage"); assert_eq!(problem_details.detail.unwrap(), "The message type for a response was incorrect or the payload was malformed."); - assert_eq!(dap_problem_type, Some(DapProblemType::UnrecognizedMessage)); + assert_eq!(dap_problem_type, Some(DapProblemType::InvalidMessage)); }); mock_collection_job_bad_request.assert_async().await; diff --git a/messages/src/lib.rs b/messages/src/lib.rs index 0e602c83b..d65901258 100644 --- a/messages/src/lib.rs +++ b/messages/src/lib.rs @@ -2275,7 +2275,7 @@ pub enum PrepareError { VdafPrepError = 5, BatchSaturated = 6, TaskExpired = 7, - UnrecognizedMessage = 8, + InvalidMessage = 8, } impl Encode for PrepareError { diff --git a/messages/src/problem_type.rs b/messages/src/problem_type.rs index 1e3968183..16267ee9c 100644 --- a/messages/src/problem_type.rs +++ b/messages/src/problem_type.rs @@ -3,9 +3,9 @@ use std::str::FromStr; /// Representation of the different problem types defined in Table 1 in §3.2. #[derive(Debug, PartialEq, Eq)] pub enum DapProblemType { - UnrecognizedMessage, + InvalidMessage, UnrecognizedTask, - RoundMismatch, + StepMismatch, MissingTaskId, UnrecognizedAggregationJob, OutdatedConfig, @@ -24,11 +24,9 @@ impl DapProblemType { /// Returns the problem type URI for a particular kind of error. pub fn type_uri(&self) -> &'static str { match self { - DapProblemType::UnrecognizedMessage => { - "urn:ietf:params:ppm:dap:error:unrecognizedMessage" - } + DapProblemType::InvalidMessage => "urn:ietf:params:ppm:dap:error:invalidMessage", DapProblemType::UnrecognizedTask => "urn:ietf:params:ppm:dap:error:unrecognizedTask", - DapProblemType::RoundMismatch => "urn:ietf:params:ppm:dap:error:roundMismatch", + DapProblemType::StepMismatch => "urn:ietf:params:ppm:dap:error:stepMismatch", DapProblemType::MissingTaskId => "urn:ietf:params:ppm:dap:error:missingTaskID", DapProblemType::UnrecognizedAggregationJob => { "urn:ietf:params:ppm:dap:error:unrecognizedAggregationJob" @@ -53,14 +51,14 @@ impl DapProblemType { /// Returns a human-readable summary of a problem type. pub fn description(&self) -> &'static str { match self { - DapProblemType::UnrecognizedMessage => { + DapProblemType::InvalidMessage => { "The message type for a response was incorrect or the payload was malformed." } DapProblemType::UnrecognizedTask => { "An endpoint received a message with an unknown task ID." } - DapProblemType::RoundMismatch => { - "The leader and helper are not on the same round of VDAF preparation." + DapProblemType::StepMismatch => { + "The leader and helper are not on the same step of VDAF preparation." } DapProblemType::MissingTaskId => { "HPKE configuration was requested without specifying a task ID." @@ -103,13 +101,11 @@ impl FromStr for DapProblemType { fn from_str(value: &str) -> Result { match value { - "urn:ietf:params:ppm:dap:error:unrecognizedMessage" => { - Ok(DapProblemType::UnrecognizedMessage) - } + "urn:ietf:params:ppm:dap:error:invalidMessage" => Ok(DapProblemType::InvalidMessage), "urn:ietf:params:ppm:dap:error:unrecognizedTask" => { Ok(DapProblemType::UnrecognizedTask) } - "urn:ietf:params:ppm:dap:error:roundMismatch" => Ok(DapProblemType::RoundMismatch), + "urn:ietf:params:ppm:dap:error:stepMismatch" => Ok(DapProblemType::StepMismatch), "urn:ietf:params:ppm:dap:error:missingTaskID" => Ok(DapProblemType::MissingTaskId), "urn:ietf:params:ppm:dap:error:unrecognizedAggregationJob" => { Ok(DapProblemType::UnrecognizedAggregationJob)