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/subscription.py", line 109, in find
File "/usr/local/lib/python2.6/dist-packages/braintree/subscription_gateway.py", line 33, in find
response = self.config.http().get("/subscriptions/" + subscription_id)
File "/usr/local/lib/python2.6/dist-packages/braintree/util/http.py", line 47, in get
return self.__http_do("GET", path)
File "/usr/local/lib/python2.6/dist-packages/braintree/util/http.py", line 70, in __http_do
File "/usr/local/lib/python2.6/dist-packages/braintree/util/http.py", 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.
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,
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.
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.
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.
yellow - Pending test for GitHub Issue #12/Mingle #2621