PagerDuty / pdpyras

Low-level PagerDuty REST/Events API client for Python
MIT License
129 stars 29 forks source link

Return None in try_decoding if body is empty #88

Closed Deconstrained closed 1 year ago

Deconstrained commented 2 years ago

If the body is empty, it seems appropriate to return None from try_decoding rather than raise JSONDecodeError.

This will resolve #87 by allowing j* methods to be used on endpoints that may respond with 204 / no content to request methods other than DELETE, i.e. the add-user-to-team endpoint.

Deconstrained commented 1 year ago

On second thought: principle of least user astonishment dictates otherwise. If the API responds with an empty body but JSON was expected, the current error (JSONDecodError or the like) best describes the issue. If None were returned and the implementation did not expect it, then that would be a breaking behavior of the client.