[Haskell-cafe] Strange encoding issue with Text and Servant
Nigel Rantor
wiggly at wiggly.org
Sat Jan 14 18:47:02 UTC 2017
On 14/01/17 17:37, Jan von Löwenstein wrote:
> Oh, it happens with servant on the client side.
>
> I use a swagger-codegen generated servant based client to access kubernetes.
> Calling https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L475 works
> Calling https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L473 doesn't.
>
> From what I see the `QueryParam"labelSelector" Text`is the same in both.
>
> Logging the value gives the literal `=` as expected. Logging the
> (http-client) requests shows the difference.
So I went ahead and wrote a simple client by hand and when I call the
two functions on a local endpoint that shows me the request URL I get
the following.
Same arguments for 'pretty' and 'labelSelector' in both cases.
Code:
runListSecret :: Manager -> BaseUrl -> ClientM SecretList
runListSecret manager baseUrl = listSecret (Just "prettyArg") (Just "=")
Nothing Nothing Nothing Nothing manager baseUrl
runListService :: Manager -> BaseUrl -> ClientM ServiceList
runListService manager baseUrl = listService (Just "prettyArg") (Just
"=") Nothing Nothing Nothing Nothing manager baseUrl
Server log:
127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET
/api/v1/secrets?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003
127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET
/api/v1/services?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003
I haven't used swagger-codegen but the servant-client code works for me
so I would look more into that.
Swagger codegen looks like it might take me a while to get my head into
so maybe you could look at the generated code, or sling it to me here or
directly.
The two calls are so similar that I can't see why the generated client
would behave differently in those cases.
Regards,
n
> Best
> Jan
>
> Nigel Rantor <wiggly at wiggly.org <mailto:wiggly at wiggly.org>> schrieb am
> Sa., 14. Jan. 2017 um 18:11 Uhr:
>
> On 13/01/17 19:28, Jan von Löwenstein wrote:
> > Hi,
> >
> > I have got a two places with a `QueryParam "q" Text` and call it
> with a
> > Text that contains a `=` literal. In one place the `=` is correctly
> > encoded as %3D, in the other I see a `!D(MISSING)`.
> >
> > This has to happen somewhere in Servant or the lower layers. Both
> Texts
> > print out nicely with an `=` sign if I just print them to stdout.
> >
> > Google does not find `!D(MISSING)` anywhere.
> >
> > Any idea what could possibly be the problem here?
>
> It would be really useful to see exactly how you are 'calling' this.
>
> Do you have a curl command line or are you using some other client?
>
> n
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
More information about the Haskell-Cafe
mailing list