oxidecomputer / oxidecomputer/omicron
test coverage for database error handling
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 572
- Forks
- 97
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 96
Description
The error handling around the database is tricky but essential. The basics are:
- Certain errors correspond with very specific error codes and messages to end users about something in their control: a constraint violation is usually "name already exists", NotFound is usually a 404, etc.
- Transient failures (that is, failure modes that are likely a result of a failing component rather than bad input or a server bug) should get a 503.
- Non-transient server failures (i.e., bugs) should get a 500.
The difference between 500 and 503 communicates to clients whether they should retry, and it'll also be very helpful for us when supporting a broken system to quickly understand the nature of the problem.
In addition to all that: for all errors, we should test that we're maintaining the detailed message that comes from the database describing what happened. Having this in the logs can be the difference between root-causing a weird issue the first time we see it vs. having to iterate with the customer.
Contributor guide
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
No files or tests are named in the issue. Start by locating the API's database error-handling entry points and existing error tests, then map constraint, NotFound, transient, and non-transient failures to the stated responses. Done means each case is covered and every error preserves the database's detailed message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, database, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100