B2_Command_Line_Tool icon indicating copy to clipboard operation
B2_Command_Line_Tool copied to clipboard

KeyError: 'buckets' when using v4.4.1, v4.3.3 works fine

Open yury-tokpanov opened this issue 5 months ago • 5 comments

Upgraded b2 recently to v4.4.1 and getting the following error when trying to sync folders:

Traceback (most recent call last):
File "/home/yury/miniconda3/bin/b2", line 5, in from b2._internal.b2v4.main import main
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2/_internal/b2v4/main.py", line 13, in
main()
~~~~^^
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2/_internal/console_tool.py", line 5623, in main
exit_status = ct.run_command(sys.argv)
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2/_internal/console_tool.py", line 5487, in run_command
return command.run(args)
~~~~~~~~~~~^^^^^^
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2/_internal/console_tool.py", line 1083, in run
return self._run(args)
~~~~~~~~~^^^^^^
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2/_internal/console_tool.py", line 3197, in _run
source = parse_folder(args.source, self.console_tool.api)
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2sdk/_internal/scan/folder_parser.py", line 35, in parse_folder
return _parse_bucket_and_folder(folder_name[5:], api, b2_folder_class)
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2sdk/_internal/scan/folder_parser.py", line 55, in _parse_bucket_and_folder
return b2_folder_class(bucket_name, folder_name, api)
File "/home/yury/miniconda3/lib/python3.13/site-packages/b2sdk/_internal/scan/folder.py", line 364, in init
self.bucket = api.get_bucket_by_name(bucket_name) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/home/yury/miniconda3/lib/python3.13/site-packages/b2sdk/_internal/api.py", line 362, in get_bucket_by_name self.check_bucket_name_restrictions(bucket_name) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/home/yury/miniconda3/lib/python3.13/site-packages/logfury/_logfury/trace_call.py", line 86, in wrapper return function(*wrapee_args, **wrapee_kwargs) File "/home/yury/miniconda3/lib/python3.13/site-packages/b2sdk/_internal/api.py", line 639, in check_bucket_name_restrictions self._check_bucket_restrictions('name', bucket_name) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/home/yury/miniconda3/lib/python3.13/site-packages/b2sdk/_internal/api.py", line 653, in _check_bucket_restrictions buckets = self.account_info.get_allowed()['buckets'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ KeyError: 'buckets'

Downgrading to v4.3.3 resolves the issue.

yury-tokpanov avatar Jul 31 '25 01:07 yury-tokpanov

@yury-tokpanov b2 v4.4.x requires b2sdk 2.9.4. Please, make sure you upgrade the sdk library alongside the CLI. LMK if the issue still persists after upgrading both packages.

olzhasar-reef avatar Jul 31 '25 11:07 olzhasar-reef

I'm having the same issue. I uninstalled and reinstalled via Homebrew. Looks like b2sdk is at 2.9.4 via Homebrew.

darinpope avatar Jul 31 '25 15:07 darinpope

This appears to be a bug, we're investigating the cause.

In the meantime, a workaround is to remove local sqlite cache (the default location is ~/.b2_account_info) and reauthorize:

rm ~/.b2_account_info
b2 account authorize <applicationKeyId> <applicationKey>

olzhasar-reef avatar Jul 31 '25 20:07 olzhasar-reef

Hi, running into this with the following call

env \
        B2_APPLICATION_KEY_ID="$1" \
        B2_APPLICATION_KEY="$2" \
        b2-wrapper sync \
        --exclude-regex "$ar_b2_default_exclude_regex" \
        $extra_args \
        "$3" "b2://$4"

EDIT

Where I get my account info with

backblaze-b2 account get

And store it locally.

My versions:

extra/python-b2sdk 2.10.0-1 (479.9 KiB 3.2 MiB) (Installed)
    Python module to access B2 cloud storage
aur/backblaze-b2 4.4.1-1 (+25 0.00) (Installed)
    Backblaze B2 Command Line Client

arichiardi avatar Aug 20 '25 17:08 arichiardi

I have the same problem with B2SDK 2.10.1. Downgrading B2 to 4.3.3 resolves the issue.

pgalbraith avatar Nov 03 '25 17:11 pgalbraith