-
Notifications
You must be signed in to change notification settings - Fork 234
GET with body sends as query string #185
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
Comments
@Nexith That's going to be the ruby core doing that. Typically a body in a GET requests is not a good idea, purely because the HTTP 1.1 spec had language to indicate it should not be supported on the server side. I know now the spec has been amended, but still you run into compatibility issues like this one. I'd recommend changing your API to accept query params instead and updating the pact to use query, rather than body. |
There is no way to tell the underlying library that in this case, the body should go in the body. For all history (until recently, it seems) GETs did not support bodies, so if we were to change that, it would break a lot of existing tests that put the "params" in the query string. |
@neilcampbell I know the HTTP 1.1 spec was unclear on this, but as you say with the amended HTTP 1.1 spec there might be a compatibility issue as you say. However I think this is a test case that should be supported as more services/products go to include a body in the GET requests as converting a complex object into a query can be hard seeing there is a limit to how long a query can be and they want to stay RESTful. @bethesque You have the pactSpecification version included in metadata, so maybe a new version could support that and change how you consume the pact json based on what version it is without breaking existing implementations? There is the |
The problem is that the underlying library that makes the request (rack test) will only allow either a body or query parameters, and it will automatically put the body in the parameters for a GET request. See this: https://github.com/rack-test/rack-test/blob/master/lib/rack/test.rb#L235 I don't think there is a way to force it to put data in the body. |
Ah, that makes things a bit harder. They seem to have a proposed solution for updating their library to make it possible see: rack/rack-test#225 There is no set release date for it, but possible a good place to make a suggestion on how this can be supported so Pact can support a body with a GET request. |
This is also worth a read swagger-api/swagger-ui#2136 for some thoughts on this. This comment in particular about the OpenAPI 3.0 take on it.
|
There seems to be a split between people thinking that it should be supported and not. I can see a case for both but, but until the RFC for HTTP 1.1 is a bit more clear it probably won't be supported by OpenAPI and Swagger at least. However I think Pact should not lift the body parameter in the GET request in put it on the query string and instead ignore it completely and only use the |
Should be fixed in 4.x with the move to Rust core instead of Ruby (or at least it'll be broken in a differnt way 😁 ) |
I have the following contract for a consumer. The request works when sending it to the server using Postman.
When the pact provider tries to verify it fails. The body is sent in the query string and not in the body of the GET request as expected.
Using the latest version of PactNet.
The text was updated successfully, but these errors were encountered: