-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aggregator API: idempotent task creation #1549
Conversation
"task with same VDAF verify key and task ID already exists with different parameters".to_string(), | ||
Status::Conflict, | ||
); | ||
return Err(datastore::Error::User(err.into())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to match on the error received by map_err below for datastore::Error::User
, try downcasting to this module's error type, and return that unwrapped error instead if it succeeds. Otherwise, duplicate tasks would just get the "Error storing task" message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I forgot to write a test for the task mutation case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: I did this to avoid writing identical match
arms for the _
case and the case where datastore::Error:User
wraps something besides aggregator_api::Error
. Too clever?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
5422828
to
8b4e9ea
Compare
8a53c17
to
a97613f
Compare
69a9546
to
c85a508
Compare
a97613f
to
31f73dd
Compare
Makes the task creation endpoint in the aggregator API idempotent, by checking whether a task corresponding to the incoming `PostTaskReq` already exists. If it does, and all the other task's parameters match the `PostTaskReq`, then we return 201 Created. If the task exists but some other parameter (e.g., min batch size) differs, we return 409 Conflict. Deletion was already correctly handled so no new changes or test were needed. Resolves #1507
31f73dd
to
4a5a9d5
Compare
Makes the task creation endpoint in the aggregator API idempotent, by checking whether a task corresponding to the incoming
PostTaskReq
already exists. If it does, and all the other task's parameters match thePostTaskReq
, then we return 201 Created. If the task exists but some other parameter (e.g., min batch size) differs, we return 409 Conflict.Deletion was already correctly handled so no new changes or test were needed.
Resolves #1507