IndexError in get_rate() method

Open
#18 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start in btcpay/client.py around line 97 and trace how get_rate() handles the empty list returned by get_rates(). Confirm the expected behavior for an empty result with maintainers; done means the reported IndexError no longer occurs when get_rates() returns [].

Written by the indexing model from the issue text.

Description

Hello guys. Thank you for the work you are doing.

Wanted to report a small bug to you. It looks like our BTCPay node is not very stable sometimes or there are some networking issues. For some reason client.get_rate("USD") occasionally may throw an IndexError list index out of range exception.

Based on the info from our Sentry dashboard I do see that get_rates() method returned an empty list and then further, on line 97 it will brake, because it tries to access the first element of the empty list rates = [] : https://github.com/btcpayserver/btcpay-python/blob/master/btcpay/client.py#L97

Not sure if you like to raise another error in that case, but just decided to report it here.

Thanks!

Dominant language
Python
Stars
79
Forks
28
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from btcpayserver/btcpay-python

All issues in btcpayserver/btcpay-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.