Skip to content

Keep query parameters on every page of a paginated stream - #1470

Open
Indian-boult wants to merge 2 commits into
oxidecomputer:mainfrom
Indian-boult:stream-keep-query-params
Open

Indian-boult wants to merge 2 commits into
oxidecomputer:mainfrom
Indian-boult:stream-keep-query-params

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 22, 2026 •

Copy link
Copy Markdown

The positional _stream method and the builder's stream set every query parameter except limit to None after the first page. Dropshot documents a second Query extractor next to PaginationParams for query parameters besides the pagination ones. Its docs say the scan parameters travel in the page token, and that required extra parameters must be supplied on each invocation. An optional extra parameter is read from each request the same way, so leaving it off a later page reads as None. Omicron uses that for silo_metric, system_metric, alert_class_list and alert_delivery_list. In the oxide.rs SDK at 621f533, the silo_metric stream sets project: Ok(None) for every page after the first, so streaming one project's metrics returns that project's measurements on the first page and silo-wide measurements after it, with no error. The alert lists lose their filters the same way.

Dropshot treats a request that carries a page_token as the next page and ignores the scan parameters, in deserialize_whichpage, and its own test sends both together. So every query parameter can go out on every page. The positional stream now passes them all through, and the builder template keeps them and resets only page_token, which each step fills in.

test_stream_pagination_extra_params in test_specific.rs runs a dropshot server whose endpoint takes a second Query that keeps only even numbers. On main both streams return the even numbers on the first page and every number after it. With the change both return only the even numbers, and the existing test_stream_pagination still passes. In the nexus outputs the positional streams pass every parameter through, and the builder streams stop resetting sort_by in 37 streams, organization in 4, project in 3, and start_time and end_time in disk_metrics_list. Dropshot ignores sort_by on later pages. A comment in dropshot_pagination still said page_token may not be sent with other query parameters, so it now says what the stream does. Streams are still generated only when every query parameter is optional. That check could be relaxed now, but I left it alone here.

#1463 adds a line just above the builder's step parameters in method.rs, so whichever of the two lands second needs a small rebase.

cargo fmt --check with nightly, the build and test steps on stable and 1.97, the trybuild tests and the no-default-features build pass. Once a release has this, regenerating oxide.rs picks it up for the CLI.

The positional `_stream` method and the builder's `stream` set every query
parameter except `limit` to None after the first page. Dropshot documents a
second `Query` extractor next to `PaginationParams` for query parameters
besides the pagination ones, and those must be sent with every page. Omicron's
`silo_metric`, `system_metric`, `alert_class_list` and `alert_delivery_list`
take one, so a stream of one project's metrics in oxide.rs returned that
project's measurements on the first page and silo-wide measurements after it.

Dropshot reads a request with a `page_token` as the next page and ignores the
scan parameters, so every query parameter can go out on every page. The
positional stream now passes them through, and the builder template resets
only `page_token`.

test_stream_pagination_extra_params runs a dropshot server whose endpoint
filters with a second `Query`, and fails on main.
The comment said page_token may not be sent with other query parameters,
which the stream code no longer assumes. Every query parameter now goes out
on every page, and dropshot ignores the scan parameters when page_token is
present.
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.

1 participant