You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use #[serde(flatten)] with query params, integers fail to parse with the following error when they are part of the nested, flattened struct:
It’s possible to accept additional query parameters besides the pagination parameters by having your API endpoint handler function take two different arguments using Query, like this:
...
You might expect that instead of doing this, you could define your own structure that includes a PaginationParams using #[serde(flatten)], and this ought to work, but it currently doesn’t due to serde_urlencoded#33, which is really serde#1183.
No worries, @davepacheco. Congrats to you and the Oxide team for shipping your first rack!
I thought that, that limitation was just for the built-in PaginationParams, which I'm not using here.
Given how deep this limitation seems to run though, I'll just go the additional query parameters route.
Thanks for the pointer!
When trying to use
#[serde(flatten)]
with query params, integers fail to parse with the following error when they are part of the nested,flatten
ed struct:Jul 07 23:10:58.044 INFO request completed, error_message_external: unable to parse query string: invalid type: string "8", expected u8, error_message_internal: unable to parse query string: invalid type: string "8", expected u8, response_code: 400, uri: /v0/projects/the-computer/branches?per_page=8&page=1, method: OPTIONS, req_id: 9fe8794e-d777-433a-8cb5-071c3ca69091, remote_addr: 127.0.0.1:64916, local_addr: 0.0.0.0:61016
Using
flatten
things look like this:However in-lining things manually works just fine, no parse errors:
Also inverting things works:
It is only when the integer field is in the nested,
flatten
ed struct that the error occurs.The text was updated successfully, but these errors were encountered: