Open pief opened 8 years ago
Note that this will break existing applications that relied on the behavior of getting an empty list in return. With this implementation, we'll almost always raise ObjectNotFound because Foreman will always return an error in its JSON.
At least for GET requests this seems to be too high of a price to me. I'd thus still propose the alternative of not raising the exception for them as a 404 upon a GET is not really an exceptional state. Nothing "failed" here, it is perfectly valid to check if a resource exists at all.
We used to always return an empty list if we got a HTTP error 404 in response to our requests, ignoring any error message possibly returned by Foreman. This makes us trigger the ObjectNotFound exception (which so far had not been used anywhere) whenever we find that the 404 is accompanied by a JSON response.