Suppose you send a request to an endpoint and expect to receive a record array field as response, like this:
{
"records": [
...
],
}
Now you are processing the response.data.records, but then you find out the records array field is not present.
Should I throw an exception? If yes, what would be the best status code to describe this error?
Consider that a request was correctly formatted and sent to the endpoint.
When I receive a proper response, I'm iterating over the array and searching for a specific object. In this case, I return a 404 when the object is not found.
But here I don't even have the response.data.records array to iterate.