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

TypeError: cannot concatenate 'str' and 'NoneType' objects #109

Closed
sharifyounes opened this issue Dec 19, 2018 · 6 comments
Closed

TypeError: cannot concatenate 'str' and 'NoneType' objects #109

sharifyounes opened this issue Dec 19, 2018 · 6 comments

Comments

@sharifyounes
Copy link

When I do subscription.find(user.subscription_id), I get this error if user.subscription_id==None. I can of course change my code to:

if user.subscription_id:
    subscription.find(user.subscription_id)

so no real issue here :)

The "offending" code is here:
https://github.com/braintree/braintree_python/blob/master/braintree/subscription_gateway.py#L38

And there's possibly a similar issue here (though it might be wise not to repr(nonce), I'm not sure):
https://github.com/braintree/braintree_python/blob/master/braintree/credit_card_gateway.py#L58

Suggesting those should be, respectively,

  • raise NotFoundError("subscription with id " + repr(subscription_id) + " not found")
  • raise NotFoundError("payment method with nonce " + repr(nonce) + " locked, consumed or not found")

Tests:

For test_subscription.py:

    @raises(NotFoundError)
    def test_finding_none_raises_not_found_exception(self):
        Subscription.find(None)

For test_credit_card.py:

    @raises(NotFoundError)
    def test_from_nonce_as_none_raises_not_found_exception(self):
        CreditCard.from_nonce(None)
@crookedneighbor
Copy link
Contributor

I looked through the other server side sdks, and most of them do implement checks around the id existing, so we do that here too. Thanks for the report.

@crookedneighbor
Copy link
Contributor

Feel free to open a PR if you'd like, otherwise, we'll add it to our backlog.

@crookedneighbor
Copy link
Contributor

I believe this is fixed now. Closing.

@crookedneighbor
Copy link
Contributor

Oh wait, it has not. Re-opening.

@crookedneighbor
Copy link
Contributor

Opened a PR internally for this, once it gets merged in and released, I'll close this issue.

@crookedneighbor
Copy link
Contributor

This is fixed in 3.55.0

jplukarski pushed a commit that referenced this issue Aug 19, 2021
…… (#327)

* BTDXCLTS-1677 - Fix issue where not found error could choke on `None` values

closes #109

* Update integration test
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