Subscription.find('') raises UnexpectedError #12

foresto opened this Issue Sep 21, 2010 · 6 comments

3 participants


While testing, I came across the following exception when calling Subscription.find(""):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/braintree/", line 109, in find
    return Configuration.gateway().subscription.find(subscription_id)
  File "/usr/local/lib/python2.6/dist-packages/braintree/", line 33, in find
    response = self.config.http().get("/subscriptions/" + subscription_id)
  File "/usr/local/lib/python2.6/dist-packages/braintree/util/", line 47, in get
    return self.__http_do("GET", path)
  File "/usr/local/lib/python2.6/dist-packages/braintree/util/", line 70, in __http_do
  File "/usr/local/lib/python2.6/dist-packages/braintree/util/", line 34, in raise_exception_from_status
    raise UnexpectedError("Unexpected HTTP_RESPONSE " + str(status))
braintree.exceptions.unexpected_error.UnexpectedError: Unexpected HTTP_RESPONSE 405

Not a big deal, since I don't expect to pass an empty string to find() in practice, but I thought you folks would like to know since it seems like the expected result would have been a NotFoundError.



Thanks for submitting this issue. It is indeed a problem with the client library. We have queued up a task to fix this and it should be included in the next release.

Braintree member


We've recently released a new version of our Python Client Library that has included a fix for this behavior. Instead of returning an UnexpectedError we'll now return a NotFoundError. We recommend you test for a blank id before calling any find method or catch this error.

Please let me know if you have any questions,

Braintree Developer

@cmonty cmonty closed this Nov 4, 2011

Thank you. Does the fix cover Customer.find() as well? One of your staff suggested Customer.find() with a nonexistent id to test the connection to the braintree server, so it looks like we'll be using this after all.

Braintree member

Yep, any find method now ensures that id is set before attempting to communicate with Braintree.


Oh? In that case, you ought to add this to the release notes. As I said, one of your staff recommended using find() with a nonexistent id to test the connection to the server. If an id of '' no longer attempts to contact the server, you have just broken this test.

Braintree member

Sorry for the confusion! We recommend using a non-existent payment method token, not an empty string. If you use an empty string, we'll respond with NotFoundError without contacting our Gateway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment