Shopify Error Responses are not logging the response body correctly
ryankazokas opened this issue · 6 comments
Problem:
There is something happening around reading the buffered response that is eating the response causing an error message like the following:
com.shopify.exceptions.ShopifyErrorResponseException: Received unexpected Response Status Code of 422
9/2/2020 1:15:40 PMResponse Headers of:
Expected Behavior
Log the error response so that the error messages are easier to debug. Without this, it's a guessing game on why the error response was returned.
Hi Ryan,
i am looking for this fix.
@chandrantwins i am currently working on a fix for this. I can't give you a definitive date, but I am hoping to get this released as soon as we are able to, along with a few other PR's that are ready for review. Sorry for the delay.
@ryankazokas please can you provide that fix here. advanced thanks for your support
I found that this is a bug with the way responses are being marshaled. For some reason the jersey client implementation of
Response.readEntity(....);
will close the input stream making it not possible to access it again in subsequent calls. It looks like according to the JAX-RS spec it's supposed to act like this, but the jersey implementation does not; even while buffering the entity.:
A message instance returned from this method will be cached for subsequent retrievals via getEntity(). Unless the supplied entity type is an input stream, this method automatically closes the unconsumed original response entity data stream if open. In case the entity data has been buffered, the buffer will be reset prior to consuming the buffered data to enable subsequent invocations of readEntity(...) methods on this response.
I'll be working on fixing this in the coming days.
@ryankazokas thanks for your reply, yes it need to fix ASAP, because currently we are not able to display any error message from shopify api response.
@chandrantwins we released 2.1.0 which should include the fix for error responses not being logged correctly and a few other items.
https://github.com/ChannelApe/shopify-sdk/releases/tag/2.1.0