playtime icon indicating copy to clipboard operation
playtime copied to clipboard

Handle Amazon Product API errors

Open leesharma opened this issue 8 years ago • 3 comments

I'm breaking this out of #56 since it's really a different issue.

The Issue

Sometimes, Amazon queries return errors. The current behavior is that the page stays blank. We should have a graceful way of handling this that gives some clue about the problem.

Here are the errors I've encountered so far (to give a sense of how they look):

  •  "Error"=>{"Code"=>"SignatureDoesNotMatch", "Message"=>"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}
    
  •  "Error"=>{"Code"=>"RequestThrottled", "Message"=>"AWS Access Key ID: <redacted>. You are submitting requests too quickly. Please retry your requests at a slower rate."}
    
  •  "Error"=>{"Code"=>"AWS.InvalidParameterValue", "Message"=>"{:ASIN=>\"B00TFT77ZS\"} is not a valid value for ItemId. Please change this value and retry your request."}}
    

And here's an example error response for the ItemLookup endpoint: gist

Reproducing the Issue

The easiest error to reproduce: search for an item with a ' character (ex. k'nex) (until #56 is solved).

Task

We should handle Amazon error responses in a generic way. Maybe re-render the search page with an flash alert? Display a different error page?

We should also make sure any sensitive data (ex. keys) are redacted from the displayed messages.

Do any of these errors need special handling? I assume the Amazon API docs list all possible errors.

leesharma avatar Oct 26 '17 03:10 leesharma

@leesharma I would like to take a shot at this issue. Do you have any extra details on the issue before I get started?

hmasila avatar Oct 26 '17 16:10 hmasila

@hmasila Not at the moment! This will probably require playing around with the response classes (lib/amazon_product_api/*_response.rb) to hold/handle errors.

leesharma avatar Oct 27 '17 02:10 leesharma

@leesharma I think I would like to try to solve this, but I wasn't sure if someone was already working on it. Is it ok if I pick this issue up?

anon0mys avatar Jul 16 '18 03:07 anon0mys