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

Shippo::Manifest.create obscures invalid transaction error with Shippo::Exceptions::ConnectionError #73

Open
oehlschl opened this issue Sep 7, 2017 · 3 comments

Comments

@oehlschl
Copy link
Contributor

oehlschl commented Sep 7, 2017

We just encountered this regression after upgrading from version 1.0 to version 3.0 of the Shippo gem/API. It looks like this was really introduced in version 2.0* and we can work around it, but it's still worth noting that the behavior is unexpected and different than Shippo clients in other languages.

Previously, invalid transactions sent to Shippo::Manifest.create were returned in the message body of a Shippo::APIError object. Now, however, a manifest request with invalid transactions results yields an underlying RestClient::NotFound exception, which is wrapped by a Shippo::Exceptions::ConnectionError here:

rescue ::RestClient::Exception => e
. The original exception message containing the invalid transactions is obscured, and, in particular, the connection error is misleading. Ideally, the actual error message would still appear accessible to the end user.

It looks like at least the PHP and Java clients treat 404s as invalid requests; see
https://github.com/goshippo/shippo-php-client/blob/master/lib/Shippo/ApiRequestor.php#L102 and https://github.com/goshippo/shippo-java-client/blob/5ee5e3068742640cc827d23ab709a5b364c8b613/src/main/java/com/shippo/net/APIResource.java#L522.

Can we we also include NotFound with the BadRequest logic here? https://github.com/goshippo/shippo-ruby-client/blob/master/lib/shippo/api/request.rb#L72

*The fallback exception class changed to ConnectionError in 2.0 (https://github.com/goshippo/shippo-ruby-client/blob/v2.0/lib/shippo/api/request.rb#L64), and the error message is no longer passed through as it was in 1.0. (https://github.com/goshippo/shippo-ruby-client/blob/v1.0.4/lib/shippo.rb#L88)

@oehlschl
Copy link
Contributor Author

oehlschl commented Sep 7, 2017

It looks like ::RestClient::BadRequest is also rescued twice (without being reraised), on both

rescue ::RestClient::BadRequest => e
and
rescue ::RestClient::BadRequest => e

@oehlschl
Copy link
Contributor Author

oehlschl commented Sep 7, 2017

It actually looks like InvalidInputError doesn't exist, possibly missed because the rescue code path is never hit. https://github.com/goshippo/shippo-ruby-client/search?utf8=%E2%9C%93&q=InvalidInputError&type=

@jfriedr
Copy link
Contributor

jfriedr commented Jul 7, 2020

@oehlschl I'm going to attempt to sift through all our outstanding issues and pull requests.

Are you still seeing this behavior or can this issue be closed out?

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