Skip to content

Explicitly include HTTP statuses in OpenAPI document for WebSockets#1554

Merged
ahl merged 5 commits intomainfrom
websocket-with-modeled-error-codes
Mar 6, 2026
Merged

Explicitly include HTTP statuses in OpenAPI document for WebSockets#1554
ahl merged 5 commits intomainfrom
websocket-with-modeled-error-codes

Conversation

@lifning
Copy link
Contributor

@lifning lifning commented Feb 27, 2026

Explicitly include HTTP statuses in OpenAPI document for WebSockets, rather than wildcard default, which made generated clients not expect any error responses from the server at all.
Also fixes description being unconditionally set to empty string in endpoints without a JSON schema (such as WebSocket endpoints).

oxidecomputer/progenitor#1320 should be applied prior to shipping this change.

This includes an API change, albeit with only minor impact: The pub type of dropshot::WebsocketEndpointResult changes from being Result<Response<Body>, HttpError>, to instead be Result<SwitchingToWebsocket, HttpError>.
The two places in our projects where this type appears would not be intrinsically broken by this change, as their only usage of it is covered by the return type of our WebsocketUpgrade::handle changing accordingly:
https://github.com/oxidecomputer/omicron/blob/339f7e4dca594f1009d885a0d9605f0df508b442/gateway/src/http_entrypoints.rs#L429-L460
https://github.com/oxidecomputer/sush/blob/5c6b64e898a906cad24618a3a82cfc4eba4908d3/server/src/server.rs#L120-L143

(issue #1548)

lif added 4 commits February 27, 2026 04:29
rather than wildcard default, which made generated clients not expect
any error responses from the server at all. (#1548)
for WebSocket channels with explicit StatusCodes,
and allowing descriptions in freeform responses
Comment on lines 46 to 48
/// [WebsocketUpgrade::handle]'s return type.
/// The `#[endpoint]` handler must return the value returned by
/// [WebsocketUpgrade::handle]. (This is done for you by `#[channel]`.)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand the situation in which a user would care about this type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One such case is described here:
https://github.com/oxidecomputer/omicron/blob/0d9b2d7ef83ac3a081972c7f4f6492440bff413f/gateway-api/src/lib.rs#L194-L218
Essentially, it's serving as an escape hatch for anyone who wishes to do pre-upgrade error reporting through HTTP (as opposed to upgrading and then reporting the error condition via a WebSocket Close frame).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have any uses that don't do (or shouldn't do) pre-upgrade error reporting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The serial-console endpoints of propolis and nexus do any error reporting in-band after the upgrade (e.g. for loss of connection with the instance), and propolis's internal API endpoint for instance migrate also does its error reporting post-upgrade, starting from the migration protocol handshake. That's not to say they have a particular reason to avoid reporting errors via HTTP, but they don't do so currently. (Of course, as we encountered, lower levels of the stack may still report an Invalid Request before getting that far)

Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens e.g. in the CLI if I try to view the serial console of a instance that doesn't exist.

@lifning lifning marked this pull request as ready for review March 3, 2026 07:28
@ahl ahl merged commit 0b5e470 into main Mar 6, 2026
12 checks passed
@ahl ahl deleted the websocket-with-modeled-error-codes branch March 6, 2026 04:19
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