Open doktor500 opened 4 years ago
Thanks @doktor500, it might be an issue with the underlying Ruby process. Will need to investigate.
Last time I checked this, I thought HTTP DELETE wasn't valid with a body (I believe HTTP 1.1 says that they may have a body, but the server might refuse the request).
That was my thoughts briefly, but a cursory google seems to indicate its up to the server implementation.
Further digging needed but it seems likely it should be supported.
So, here's the current delete spec: https://tools.ietf.org/html/rfc7231#section-4.3.5
A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request.
This is like the body in GET - you're allowed to include one, but it doesn't mean anything, and it might mean a spec-compliant server rejects the request.
We had a similar discussion about GET, where I argued that we shouldn't support this. (see here: https://github.com/pact-foundation/pact-node/issues/183 )
We also had this same issue reported earlier, where I thought it was fixed upstream (but didn't check the spec at that time): https://github.com/pact-foundation/pact-node/issues/183
I'm starting to change my mind on this one, since we get this question a lot, and it's clear what the user intends (even if it's not spec compliant). I think the biggest challenge is cross-language support, since implementations are allowed to reject deletes with bodies.
I think the ideal behaviour is to allow the user to specify DELETE with body (and to have a mock server that allows this), but to warn that it's not valid. What do you think?
Ideally it would be nice to offer that functionality, but unless Rack Test supports it, it can't actually be done in the Ruby Implementation. It might need to wait until we move to Rust.
I haven't tried myself, but if you're game, you could try https://github.com/pact-foundation/pact-js/#pact-js-v3 a go (it's in beta, but is supported so we will fix bugs etc.).
This could be tested with the latest 10.x.x library. I suspect it will suffer the same fate.
I think you could close this one. There isn't any meaning to a delete body.
I think you could close this one. There isn't any meaning to a delete body.
I agree with you that's how it should be interpreted, but my reading of the RFC is that it's undefined - so a server can interpret that how it wishes. As a framework, we should be cautious expressing too strong of an opinion there. I've dropped the bug
label, because I don't think we should call it a bug, but if it can be supported in one way or improved (your suggestion above on a "warn" might be one way to do that) then I'm open to that.
Issue Classification
Bug Report
Contracts for HTTP
DELETE
requests that contain a JSON body can't be verified in the provider.Software versions
@pact-foundation/pact": "^9.11.0
@pact-foundation/pact": "^9.11.0
v12.10.0
Issue Checklist
Confirm the following:
Expected behaviour
A contract for an HTTP DELETE request with a JSON body can be verified in the provider
Actual behaviour
A contract for an HTTP DELETE request with a JSON body can't be verified in the provider
Steps to reproduce
https://github.com/doktor500/pact-delete-bug
Relevant log files