Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown error due to failure in parsing #136

Closed
andrewhavens opened this issue Aug 30, 2019 · 1 comment
Closed

Unknown error due to failure in parsing #136

andrewhavens opened this issue Aug 30, 2019 · 1 comment

Comments

@andrewhavens
Copy link
Contributor

I noticed an error in our logs:

undefined method `[]' for nil:NilClass

After further investigation, I realized it was happening inside peddler. A call to get_fulfillment_order resulted in an error response from MWS. However, peddler had a problem trying to determine the error code.

/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/errors/parser.rb:18:in `code' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/errors/builder.rb:47:in `error_name' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/errors/builder.rb:39:in `bad_class_name?' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/errors/builder.rb:31:in `build' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/errors/builder.rb:20:in `call' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/client.rb:152:in `handle_http_status_error' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/client.rb:121:in `rescue in run'
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/peddler/client.rb:113:in `run' 
/app/vendor/bundle/ruby/2.5.0/bundler/gems/peddler-73bd11b2d04b/lib/mws/fulfillment_outbound_shipment/client.rb:113:in `get_fulfillment_order' 

I looked at the peddler source, and it looks like the problem is that parse returned nil. https://github.com/hakanensari/peddler/blob/master/lib/peddler/errors/parser.rb#L18

Unfortunately, I'm not sure what the response looked like, since the HTTP requests aren't being logged in production.

I'm not sure exactly what the solution should be. Maybe peddler should default to something if it can't determine the error code. If there's some sort of MWS error response logging that I can enable, that would be helpful, but I don't know if such a feature exists.

@hakanensari
Copy link
Member

@andrewhavens, thanks for reporting.

This looks like an edge case. I'm adding a guard so we correctly bubble up the original HTTP status error.

About logging, I think it's best if you did this on your end? When hitting MWS, you could simply rescue, log, and re-raise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants