smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

Incorrect/strange handling of query parameters without a value

Open kubukoz opened this issue 1 year ago • 4 comments

Consider the following URI:

?foo=bar&foo&foo=baz

On http4s level, the query.pairs contains the whole truth: Vector((foo,Some(bar)), (foo,None), (foo,Some(baz))).

However, in the conversion to smithy4s.http.HttpUri, we're converting all Nones to true. In 0.18 (0.19 is so far the same):

https://github.com/disneystreaming/smithy4s/blob/b6c789785d6085161de9d1d42469783696360112/modules/http4s-kernel/src/smithy4s/http4s/kernel/package.scala#L187-L196

The outcome of this is that, if you have a @httpQuery @sparse list of strings, instead of Nones you'll see Some(true).

IMO this is an issue - we're discarding information about the None too soon.

I assume this is not changeable in 0.18 because we'd have to change the URI model:

https://github.com/disneystreaming/smithy4s/blob/b6c789785d6085161de9d1d42469783696360112/modules/core/src/smithy4s/http/HttpUri.scala#L27

unless... we use nulls. Which is probably worse than waiting for 0.19.

kubukoz avatar Apr 15 '24 15:04 kubukoz

Yeah I'm happy to change the modelling of HttpUri in 0.19. As a matter of fact we already have, to make the host optional and better cater to JS

Baccata avatar Apr 15 '24 15:04 Baccata

cool, this is up for grabs then 😄

kubukoz avatar Apr 15 '24 16:04 kubukoz

@denisrosca is on it

kubukoz avatar Apr 19 '24 14:04 kubukoz