From 538818d1c3834f13450725fb91706c62df03eb25 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Mon, 22 Apr 2024 22:28:35 +0200 Subject: [PATCH] fix `create-key --all-capabilities` when account doesnt have access to notification-rules cap --- b2/_internal/console_tool.py | 9 ++++++++- changelog.d/+create_key.fixed.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelog.d/+create_key.fixed.md diff --git a/b2/_internal/console_tool.py b/b2/_internal/console_tool.py index 9376eb4ab..bc7e258c7 100644 --- a/b2/_internal/console_tool.py +++ b/b2/_internal/console_tool.py @@ -1643,7 +1643,14 @@ def _run(self, args): bucket_id_or_none = self.api.get_bucket_by_name(args.bucket).id_ if args.all_capabilities: - args.capabilities = ALL_CAPABILITIES + current_key_caps = set(self.api.account_info.get_allowed()['capabilities']) + preview_feature_caps = { + 'readBucketNotifications', + 'writeBucketNotifications', + } + args.capabilities = sorted( + set(ALL_CAPABILITIES) - preview_feature_caps | current_key_caps + ) application_key = self.api.create_key( capabilities=args.capabilities, diff --git a/changelog.d/+create_key.fixed.md b/changelog.d/+create_key.fixed.md new file mode 100644 index 000000000..a7c9bab99 --- /dev/null +++ b/changelog.d/+create_key.fixed.md @@ -0,0 +1 @@ +Fix `create-key --all-capabilities` erroring out when new b2sdk is installed.