Skip to content
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

Fix panic when trying to get HPKE configs on a task that doesn't have any configured #1738

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

inahga
Copy link
Contributor

@inahga inahga commented Aug 16, 2023

Supports #1568.

If a taskprov task is present, the end-user can still query /hpke_configs?task_id=foo. If they do this, the handler will panic because we have an unwrap in the task-specific handle_hpke_config() function. Taskprov tasks don't have any HPKE keys directly associated with them.

        HpkeConfigList::new(Vec::from([self
            .task
            .hpke_keys()
            .iter()
            .max_by_key(|(&id, _)| id)
            .unwrap()
            .1
            .config()
            .clone()]))

Partially fix this by unconditionally returning the global keys when in taskprov mode, so any client task_id parameters are ignored.

This doesn't handle the case where a taskprov task is in the database, the system is out of taskprov mode, and a client queries /hpke_configs?task_id=foo. I figure this is a niche enough case that we can ignore it, however I wrapped it in a comment and nicer error handling logic.

This awkward logic goes away if we adopt #1641. I'm also open to cleaner ways of handling this case.

@inahga inahga requested a review from a team as a code owner August 16, 2023 20:19
// Assuming something hasn't gone horribly wrong with the database, this
// should only happen in the case where the system has been moved from taskprov
// mode to non-taskprov mode. Thus there's still taskprov tasks in the database.
// This isn't a supported use case, so the operator needs to delete these tasks
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated #1736 to back up this assertion.

@inahga inahga merged commit beb92c7 into main Aug 16, 2023
7 checks passed
@inahga inahga deleted the inahga/fix-hpke-config-bug branch August 16, 2023 21:56
inahga added a commit that referenced this pull request Aug 18, 2023
inahga added a commit that referenced this pull request Aug 18, 2023
inahga added a commit that referenced this pull request Aug 18, 2023
…er-01 (#1748)

* Split aggregator_api/src/lib.rs (#1683)

* Minor aggregator API cleanup (#1694)

* Deletion should return 204 on not found, not 404.

It's not really an error if we try to delete something and it's already been deleted. This also
makes the deletion request idempotent.

* Provide explicit return type in routes

* Remove needless Halt

I'm pretty sure this Halt isn't required and is just noisy. Other routes don't use it.

* Aggregator API error handling cleanup (#1698)

* Aggregator API error handling cleanup

As this crate grows, having to map each error is becoming burdensome.

Mainly turns `Error` into a enum from a struct. We can map errors into variants that handle HTTP
status codes for us, and use `#[from]` to let us use `?` on datastore errors.

We do lose a little bit of tracing in this PR. Datastore errors are unaffected, because datastore
methods are already traced. But handler-local internal error paths aren't well traced, some context
might be missing since we'll only see the final result. There's ways around this, but the internal
error cases look to be _very_ unlikely to happen (and likely should be unwraps anyways), so I don't
think it's worth spending much time on.

* PR feedback

* Fix flaky test that occasionally collides on random() (#1729)

* Add peer aggregator endpoints to aggregator API (#1689)

* Aggregator API endpoints for configuring taskprov peer aggregator

* Remove querystring as a dependency

* Align custom serde with other implementations

* Clippy

* Clippy lints that don't show up locally 🤷

* Provide role and endpoint in request body

* Revert "Remove querystring as a dependency"

This reverts commit 74de8a7.

* Remove serde_urlencoded

Cargo wants to remove random things 🤷

* Remove unneeded error

* Fix panic when trying to get HPKE configs on a task that doesn't have any configured (#1738)

* Document taskprov extension and global HPKE keys (#1736)

* Document taskprov extension and global HPKE keys

* Typo

* Once you go taskprov, you never go back

* Spacing

Co-authored-by: Tim Geoghegan <[email protected]>

* Typo

Co-authored-by: Tim Geoghegan <[email protected]>

* Wording

Co-authored-by: Tim Geoghegan <[email protected]>

* We're doing taskprov-04 for dap-02

---------

Co-authored-by: Tim Geoghegan <[email protected]>

---------

Co-authored-by: Tim Geoghegan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants