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

Assertion Error when passing invalid address #88

Closed
NoWay426 opened this issue Mar 31, 2020 · 2 comments
Closed

Assertion Error when passing invalid address #88

NoWay426 opened this issue Mar 31, 2020 · 2 comments

Comments

@NoWay426
Copy link

NoWay426 commented Mar 31, 2020

I'm running into an issue when using the python module vs using requests.get(https://api.blockcypher/...)

When checking an address via requests, if the address is invalid a dict item is still returned.

{"error": "Address <invalid_address> is invalid: Address <invalid address> is of unknown size."}

When using the module, an assertion error is thrown for get_address_details() that will crash the script.

>>> response = blockcypher.get_address_details("<invalid addr>")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\X\AppData\Local\Programs\Python\Python38-32\lib\site-packages\blockcypher\api.py", line 122, in get_address_details
    assert is_valid_address_for_coinsymbol(
AssertionError: <invalid addr>

This is rather inconvenient when iterating over a list of several addresses, if one happens to have a typo, be invalid etc. Would be easy to handle if the same dict["error"] was returned as in first example.

Please forgive if there's something simple I'm missing here.

@NoWay426
Copy link
Author

Ah yes, I can see I need forgiveness for this one. Should've learned exception handling "Try" "Except" before posting this.

Leaving it up nonetheless, since the discrepancy between the module return vs request.get(url) return may be of value.

@quentinlesceller
Copy link
Contributor

Thanks for the PR @NoWay426. Glad you managed to fix your issue. Closing.

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