oxidecomputer / oxidecomputer/omicron

HTML error pages for HTML-wanting requests

Open
#3,333 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

When we 404 (or other error) in the browser we currently return JSON. This is a terrible mediocre user experience. In general, we should default to JSON responses because Nexus is primarily a JSON API. Fortunately, as you can see in the screenshot, when we get a request from a browser (or more concretely, a request to which we would prefer to respond with HTML) we can tell from the Accept header on the request.

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8

We could instead use the presence or lack of /v1 prefix on the path, since that's the implicit marker for API vs. Console requests, but I think the HTML header is better: we're just doing what they tell us to do. They say they want HTML, give them HTML.

What should the HTML be? The web console currently generates the assets served as console pages, including an index.html which is mostly a dummy container for a React app to run in. The console can easily generate other HTML pages (Vite docs on multiple entry points). This has the advantage of keeping the console responsible for all HTML and CSS, and we could reuse our existing styling.

image

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

Start by inspecting the web console's generated index.html and its existing asset generation, then review the Vite multi-page entry-point approach described in the issue. Done means browser requests advertising HTML receive styled HTML error pages, while JSON remains the default for API-oriented requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html, react, vite
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.