hvac icon indicating copy to clipboard operation
hvac copied to clipboard

The JSON adapter should return an empty response on 204 rather than the response object

Open briantist opened this issue 4 years ago • 1 comments

https://github.com/hvac/hvac/blob/ec048ded30d21c13c21cfa950d148c8bfc1467b0/hvac/adapters.py#L365-L371

On a 204 response, the entire response object is returned, but I think it should be an empty dict instead (or maybe None would be fine as well), to be more consistent, since Vault is known to return 204 responses when it has nothing to say, and that result is more appropriate to deal with as a client.

As an example, if I want to test for this case, I need to import requests and test the the type of the response, or I can try checking for a status_code field, but if the vault request returned some data with a status_code field, then I can't rely on that.

There's a number of workarounds I can think of to handle this, but it'd be better for this common response type to be handled by the adapter in a way that's friendlier to deal with on the client side.

briantist avatar Mar 02 '22 04:03 briantist

A fix for this should also close out these I think:

  • #293
  • #385
  • #660

briantist avatar Jul 30 '22 12:07 briantist