oxidecomputer / oxidecomputer/dropshot
Provide better experience when POSTing an empty body on an endpoint that only has optional body params
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 104
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 22
Description
Recently we added /v1/disks/{disk}/finalize to Oxide's API which has a post body of { snapshot_name: Option<Name> }. One might assume that you could simply not specify a POST body when calling the endpoint and it would be handled correctly. That assumption is wrong. Currently the empty string of the POST gets passed to serde which gives us a lovely error of unable to parse JSON body: EOF while parsing a value at line 1 column 0. Now if you know that serde is responsible for parsing the POST body and you know that an empty string is invalid JSON then this error makes complete sense. I do not expect consumers of our API (or other APIs using dropshot) to have that knowledge.
We have a few options here.
- We could make an update such that dropshot understands that a
Bodycan be optional. This is the ideal implementation imo because it just works™. The best error is no error. - We just improve the error message just to inform folks that the body can't be empty. This is likely much easier and a perfectly fine bridge between where we are and where we want to be.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the POST to /v1/disks/{disk}/finalize with an empty body and inspect Dropshot's request-body parsing path. The issue presents two possible outcomes—accepting an omitted body or improving the error—so completion requires choosing one and verifying the resulting behavior for optional body parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100