wesselt / bunq2ynab

Upload bunq transactions to ynab
Other
78 stars 22 forks source link

List Users generates Error message: "IndexError: list index out of range" #69

Closed SirCampsalot1611 closed 1 week ago

SirCampsalot1611 commented 1 week ago

When execting list_users, following error message is shown, since yesterday:


raceback (most recent call last):
  File "list_user.py", line 26, in <module>
    print_accounts(v)
  File "list_user.py", line 12, in print_accounts
    for a in bunq_api.get_accounts_for_user(u):
  File "/home/michi/bunq2ynab/bunq2ynab_hauptkonto/lib/bunq_api.py", line 119, in get_accounts_for_user
    iban = [a["value"] for a in a["alias"] if a["type"] =="IBAN"][0]
IndexError: list index out of range

Syncing accounts is not possible

wesselt commented 1 week ago

Thanks for your report! It looks like there's an account without IBAN?

What do you think of sharing the output of when you list users with the verbose -v parameter? (Mind you, that's a lot of text.)

SirCampsalot1611 commented 1 week ago

now where you mention it: Yesterday I have linked an external bankaccount in bunq. Ive unlinked it, its in the archive of bunq now. The error still occured. unfortunately I cannd delete that account


 "Response": [
    {
      "MonetaryAccountSavings": {
        "id": XXXX,
        "created": "2019-01-01 12:10:37.616678",
        "updated": "2021-02-03 16:12:39.341293",
        "alias": [
          {
            "type": "IBAN",
            "value": "NL84BUNQXXXXXX",
            "name": "Michael XXXX"
          }
        ],
        "avatar": {
          "uuid": "XXXX-44e0-4d52-8b8c-XXXX",
          "image": [
            {
              "attachment_public_uuid": "XXXX-2cbd-41ca-83f3-XXXXX",
              "height": 1024,
              "width": 1024,
              "content_type": "image/png",
              "urls": [
                {
                  "type": "ORIGINAL",
                  "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/bunq_file/File/content/33550336a393bf1e06b80060488b332193839cf0079190cbe313cb6352e2d60f.png"
                }
              ]
            }
          ],
          "anchor_uuid": "c1c2fb9d-25ba-476e-a074-XXXX",
          "style": "NONE"
        },
        "balance": {
          "currency": "EUR",
          "value": "0.00"
        },
        "country": "NL",
        "currency": "EUR",
        "display_name": "Michael XXXX",
        "daily_limit": {
          "currency": "EUR",
          "value": "1000.00"
        },
        "description": "Schlechte Zeiten",
        "public_uuid": "XXXXX-25ba-476e-a074-XXXX",
        "status": "CANCELLED",
        "sub_status": "PERMANENT",
        "timezone": "europe/amsterdam",
        "user_id": XXXXX,
        "monetary_account_profile": null,
        "setting": {
          "color": "#0080ff",
          "icon": null,
          "default_avatar_status": "AVATAR_DEFAULT",
          "restriction_chat": "ALLOW_INCOMING",
          "sdd_expiration_action": "AUTO_ACCEPT"
        },
        "connected_cards": [],
        "budget": [],
        "credit_line": null,
        "savings_goal": {
          "currency": "EUR",
          "value": "XXXX"
        },
        "savings_goal_progress": "0",
        "number_of_payment_remaining": 2,
        "all_auto_save_id": []
      }
    },
    {
      "MonetaryAccountBank": {
        "id": XXXX,
        "created": "2018-12-24 17:29:56.522169",
        "updated": "2021-02-03 16:12:39.315781",
        "alias": [
          {
            "type": "IBAN",
            "value": "NL95BUNQXXXXX",
            "name": "Michael XXXX"
          }
        ],
        "avatar": {
          "uuid": "35d778d1-ce40-4065-b9de-XXXXX",
          "image": [
            {
              "attachment_public_uuid": "0fa8b9f6-8b4a-4586-8573-XXXXX",
              "height": 587,
              "width": 587,
              "content_type": "image/jpeg",
              "urls": [
                {
                  "type": "ORIGINAL",
                  "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/bunq_file/File/content/dc2af808853e4d9d36a6a2043f3d83e5a08658b878707e38bd0379d0b64a9c82.jpg"
                }
              ]
            }
          ],
          "anchor_uuid": "41439ea1-64f4-42b3-91f1-XXXXX",
          "style": "NONE"
        },
        "balance": {
          "currency": "EUR",
          "value": "0.00"
        },
        "country": "NL",
        "currency": "EUR",
        "display_name": "Michael XXXX",
        "daily_limit": {
          "currency": "EUR",
          "value": "XXXX"
        },
        "description": "Urlaubskonto",
        "public_uuid": "41439ea1-64f4-42b3-91f1-XXXXX",
        "status": "ACTIVE",
        "sub_status": "NONE",
        "timezone": "europe/amsterdam",
        "user_id": XXXX,
        "monetary_account_profile": null,
        "setting": {
          "color": "#ffcd00",
          "icon": null,
          "default_avatar_status": "AVATAR_CUSTOM",
          "restriction_chat": "ALLOW_INCOMING",
          "sdd_expiration_action": "AUTO_ACCEPT"
        },
        "connected_cards": [],
        "budget": [],
        "overdraft_limit": {
          "currency": "EUR",
          "value": "0.00"
        },
        "all_auto_save_id": []
      }
    },
    {
      "MonetaryAccountBank": {
        "id": XXXX,
        "created": "2018-12-19 22:21:31.382301",
        "updated": "2024-02-21 15:28:29.176973",
        "alias": [
          {
            "type": "IBAN",
            "value": "NL93BUNQXXXXX",
            "name": "Michael XXXX"
          },
          {
            "type": "EMAIL",
            "value": "XXXX",
            "name": "XXXXX"
          },
          {
            "type": "PHONE_NUMBER",
            "value": "XXX",
            "name": "XXXX"
          },
          {
            "type": "URL",
            "value": "https://bunq.me/MXXXX",
            "name": "https://bunq.me/MXXXX"
          }
        ],
        "avatar": {
          "uuid": "e92a86fa-d6b4-4636-8e15-XXXX",
          "image": [
            {
              "attachment_public_uuid": "04a71b3e-3d3d-41a9-98a7-XXXXX",
              "height": 1024,
              "width": 1024,
              "content_type": "image/jpeg",
              "urls": [
                {
                  "type": "ORIGINAL",
                  "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/bunq_file/File/content/229de863b4d5e8cc33fecbf72a48e00db0a88627c756c5363e3591c73c0f40c5.jpg"
                }
              ]
            }
          ],
          "anchor_uuid": "08dcb450-7e95-4081-99a5-XXXXX",
          "style": "NONE"
        },
        "balance": {
          "currency": "EUR",
          "value": "XXXXX"
        },
        "country": "NL",
        "currency": "EUR",
        "display_name": "Michael XXXX",
        "daily_limit": {
          "currency": "EUR",
          "value": "XXXX"
        },
        "description": "Bunq_Hauptkonto",
        "public_uuid": "08dcb450-7e95-4081-99a5-XXXX",
        "status": "ACTIVE",
        "sub_status": "NONE",
        "timezone": "europe/amsterdam",
        "user_id": XXXX,
        "monetary_account_profile": {
          "profile_fill": {
            "status": "ACTIVE",
            "balance_preferred": {
              "currency": "EUR",
              "value": "XXXX"
            },
            "balance_threshold_low": {
              "currency": "EUR",
              "value": "XXXX"
            }
          },
          "profile_drain": null,
          "profile_action_required": "NO_ACTION_NEEDED",
          "profile_amount_required": {
            "currency": "EUR",
            "value": "0.00"
          }
        },
        "setting": {
          "color": "#0080ff",
          "icon": "HOUSEHOLD_EXPENSES",
          "default_avatar_status": "AVATAR_ICON",
          "restriction_chat": "ALLOW_INCOMING",
          "sdd_expiration_action": "AUTO_ACCEPT"
        },
        "connected_cards": [],
        "budget": [],
        "overdraft_limit": {
          "currency": "EUR",
          "value": "0.00"
        },
        "all_auto_save_id": []
      }
    }
  ],
  "Pagination": {
    "future_url": null,
    "newer_url": "/v1/user/739753/monetary-account?newer_id=XXXX1102371",
    "older_url": null
  }
}
2024-11-25 15:11:45,259 | DEBUG | bunq.py:160 | log_reply | ******************************
Traceback (most recent call last):
  File "list_user.py", line 26, in <module>
    print_accounts(v)
  File "list_user.py", line 12, in print_accounts
    for a in bunq_api.get_accounts_for_user(u):
  File "/home/michi/bunq2ynab/bunq2ynab_hauptkonto/lib/bunq_api.py", line 119, in get_accounts_for_user
    iban = [a["value"] for a in a["alias"] if a["type"] =="IBAN"][0]
IndexError: list index out of range
SirCampsalot1611 commented 1 week ago

sinc I am not able to delete that external account, I really would appreciate it, if you could fix it. :)

wesselt commented 1 week ago

It looks like all three bank accounts in the reply have an alias of type IBAN. Which account was the offending one?

SirCampsalot1611 commented 1 week ago

In this case i think my external account was not the bad account. Its not showing up in that list cause i didnt choose to sync it. Sory, my bad. But so I have no idea which of the accounts could be the offending one. Could you give me a hint how to find out?

wesselt commented 1 week ago

It looks like there's already a check for "MonetaryAccountExternal": https://github.com/wesselt/bunq2ynab/blob/baf4ffc11feb2e73fc6adee2cb6b1a6740755b75/lib/bunq_api.py#L114

What do you think of printing the account name on line 116? The last one printed before the exception should be the problem.

SirCampsalot1611 commented 1 week ago

sure you want Line 116? This line shows the timezone. If you prove me your email address, I would send you the complete script without XXs

wesselt commented 1 week ago

Timezone on line 116? Are you sure you are using the latest version?

My email is wesselt at aule dot net

SirCampsalot1611 commented 1 week ago

I am so sorry - I didn´t use the latest version. It works now. But thank you for your help!

wesselt commented 1 week ago

Good to hear, thanks for reporting back!