oxidecomputer / oxidecomputer/omicron

Use of `bail_unless!` is highly problematic

Open
#11,051 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api cleanup Good for new hires important non-blocker trust quorum
Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

Throughout trust quorum, and likely in other cases, we return errors when invariants aren't met. The easiest way to do this inside a transaction is to call the bail_unless! macro. Unfortunately this always returns a 500 error that is then likely to be presented to the API. It would be better to not use this, or to build a similar macro that can return better error codes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the trust quorum transaction paths and all uses of the bail_unless! macro, starting with how invariant failures are converted into API responses. Determine the intended error codes and identify the affected callers; done means those invariant failures no longer become generic 500 responses and the behavior is covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.