oxidecomputer / oxidecomputer/omicron

Query params that should be required in OpenAPI spec are not

Open
#2,575 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

image_list_v1 is wrong

image_list_v1 requires a project selector in the query string, which means you need at least a project identifier, but if you use a project ID (as opposed to a name), you don't need the org identifier. So the org is optional but the project is required.

https://github.com/oxidecomputer/omicron/blob/4e98516befcec14b669840c4f5bb6674e76cabc6/nexus/src/external_api/http_entrypoints.rs#L4968-L4973

And the struct reflects that: project has type NameOrId, but the org selector is optional.

https://github.com/oxidecomputer/omicron/blob/4e98516befcec14b669840c4f5bb6674e76cabc6/nexus/types/src/external_api/params.rs#L165-L170

But in the OpenAPI spec, the project selector does not get required: true like you would expect.

https://github.com/oxidecomputer/omicron/blob/4e98516befcec14b669840c4f5bb6674e76cabc6/openapi/nexus.json#L8310-L8316

But image_create_v1 is fine

image_create_v1, by contrast, does get the expected params: project is required and org is optional. This endpoint uses the much simpler Query<params::ProjectSelector> so it seems the problem is introduced by having multiple layers of wrappers with #[serde(flatten)] to hide them.

https://github.com/oxidecomputer/omicron/blob/4e98516befcec14b669840c4f5bb6674e76cabc6/nexus/src/external_api/http_entrypoints.rs#L5054-L5056

https://github.com/oxidecomputer/omicron/blob/4e98516befcec14b669840c4f5bb6674e76cabc6/openapi/nexus.json#L8353-L8367

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 in nexus/src/external_api/http_entrypoints.rs and nexus/types/src/external_api/params.rs, then compare image_list_v1 with the working image_create_v1 definition. Inspect the generated entry in openapi/nexus.json and the serde(flatten) wrappers; done means the image_list_v1 project query parameter is required while org remains optional.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.