From cee5fe77e1535c69ee829aba830040499e4a225b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Murta?= Date: Thu, 1 Jan 2026 19:05:37 +0000 Subject: [PATCH] feat: improve GoCardless error handling Handle 409 when retriving transactions, which signals the account data is still being processed, and 429, which signals the rate lite was exceeded. --- pfbudget/extract/nordigen.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pfbudget/extract/nordigen.py b/pfbudget/extract/nordigen.py index 25b68cd..56d786d 100644 --- a/pfbudget/extract/nordigen.py +++ b/pfbudget/extract/nordigen.py @@ -61,6 +61,21 @@ class NordigenClient: retries += 1 print(f"Request #{retries} timed-out, retrying in 1s") time.sleep(1) + except requests.HTTPError as e: + if ( + e.response.status_code == 409 + and e.response.type == "AccountProcessing" + ): + timeout = 1 + while account.get_metadata()["status"] != "READY": + print(f"Waiting for status ready, retrying in {timeout}s") + time.sleep(timeout) + timeout *= 2 + elif e.response.status_code == 429: + print("Rate limit exceeded for today, aborting") + break + else: + raise DownloadError(e) if not downloaded: print(f"Couldn't download transactions for {account.get_metadata()}")