Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [haskell-http-client] Incorrectly generated query strings #3459

Closed
4 of 6 tasks
jpgneves opened this issue Jul 25, 2019 · 3 comments · Fixed by #10424
Closed
4 of 6 tasks

[BUG] [haskell-http-client] Incorrectly generated query strings #3459

jpgneves opened this issue Jul 25, 2019 · 3 comments · Fixed by #10424

Comments

@jpgneves
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When generating request URIs, the generated code uses Query for the query type, which escapes characters like +, which should not escaped, for instance, for the Kubernetes API client.

In the Kubernetes API client, we should be able to generate queries like ?labelSelector=environment+in+%28production%2Cqa%29%2Ctier+in+%28frontend%29 (from https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering). Right now, the generated URIs URL-encode the plus signs, which the API server rejects.

openapi-generator version

Commit number c9737cf97d5e31936639842d389118e980ee85a9 (from https://github.com/kubernetes-client/haskell/blob/master/settings)

OpenAPI declaration file content or url

https://github.com/kubernetes-client/haskell/blob/master/kubernetes/openapi.yaml

Command line used for generation

In the directory where https://github.com/kubernetes-client/haskell/ is checked out:
../gen/openapi/haskell.sh . ./settings

Steps to reproduce

Build the generator.
Use it in a code base that does something like the following:

let request = listEndpointsForAllNamespaces (Accept MimeJSON)
    selector = LabelSelector $ "foo+in+(bar)"
in do
  _ <- dispatchMime' manager config $ request -&- selector

Verify that the generated request has URL-encoded the + signs.

Related issues/PRs
Suggest a fix

To resolve this situation, the generated code should use PartialEscapeQuery instead, which sadly is a more complex type as the underlying items are no longer Maybe ByteString, but instead are EscapeItem, so it becomes a larger refactoring

@auto-labeler
Copy link

auto-labeler bot commented Jul 25, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@jonschoning
Copy link
Contributor

I just saw this bug now, unfortunately. I'll take a look, thanks.

@jonschoning
Copy link
Contributor

cf: kubernetes-client/haskell#67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants