tducret / revolut-python

Non-official client for the Revolut Bank
MIT License
103 stars 25 forks source link

Infinite loop in get_account_transactions #34

Open ishfx opened 3 years ago

ishfx commented 3 years ago

Hey,

I have a script using your wonderful library which has been working great so far. When i ran it earlier this day, i got an unexpected result; it hang.

I had to dig to find out why it got into this state.

The issue comes from the method get_account_transactions. https://github.com/tducret/revolut-python/blob/master/revolut/__init__.py#L186

get_account_transactions never breaks from the infinite loop because the revolut api always returns a transaction. To be more precise, the first call to the api (so first loop) returns N transactions, to param is updated with the datetime of the last retrieved transaction, then the second loop (and those after) always return 1 transaction => stuck in loop.

I don't understand the need for the loop here, are there any specific cases ?

Right now, i just removed the loop to solve the issue because the first api call returns the requested transactions.

Thanks in advance.

leikoilja commented 3 years ago

Thank you, @IshFx, for a good spot. Feel free to open a PR with changes, but make sure it accounts for transaction pagination. I agree with you that the loop is not well/safely implemented and can be refactored. Maybe @cosmincc(https://github.com/tducret/revolut-python/commit/2e816d205ebbf755527abb6dcde99382c4cd1b4c) can take a look at that?