riweston / aztx

MIT License
18 stars 3 forks source link

The command failed with an unexpected error. Here is the traceback: 'environmentName' #36

Open sergeibelov113 opened 1 month ago

sergeibelov113 commented 1 month ago

Doesn't work right on my side. When I install it through brew, aztx allows me to see and choose subscription. But when I chose any subscription and then tries to connect to kubernetes cluster for example - it throws some weird python errors regarding environmentName.

Even az account command stopped working and throws the same error. Only az account clear and az login then works. But when I run aztx - the same issue repeats.

az account show
The command failed with an unexpected error. Here is the traceback:
'environmentName'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 363, in handler
    show_exception_handler(ex)
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/arm.py", line 432, in show_exception_handler
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 361, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/profile/custom.py", line 70, in show_subscription
    return profile.get_subscription(subscription)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/_profile.py", line 567, in get_subscription
    subscriptions = self.load_cached_subscriptions()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/_profile.py", line 553, in load_cached_subscriptions
    cached_subscriptions = [sub for sub in subscriptions
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.62.0/libexec/lib/python3.11/site-packages/azure/cli/core/_profile.py", line 554, in <listcomp>
    if all_clouds or sub[_ENVIRONMENT_NAME] == active_cloud.name]
                     ~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'environmentName'

➜  ~ brew info aztx
==> riweston/aztx/aztx: stable 1.1.0
This tool is a helper for azure-cli that leverages fzf for a nice interface to switch between subscription contexts.
https://github.com/riweston/aztx
Not installed
From: https://github.com/riweston/homebrew-aztx/blob/HEAD/aztx.rb
License: MIT
==> Dependencies
Required: azure-cli ✔, fzf ✔
➜  ~
➜  ~
➜  ~
➜  ~
➜  ~ brew info azure-clie
Error: No available formula with the name "azure-clie". Did you mean azure-cli?
➜  ~ brew info azure-cli
==> azure-cli: stable 2.62.0 (bottled), HEAD
Microsoft Azure CLI 2.0
https://docs.microsoft.com/cli/azure/overview
Installed
/opt/homebrew/Cellar/azure-cli/2.61.0 (27,535 files, 639.6MB)
  Poured from bottle using the formulae.brew.sh API on 2024-05-21 at 22:20:37
/opt/homebrew/Cellar/azure-cli/2.62.0 (27,344 files, 634.3MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-07-10 at 11:24:41
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/a/azure-cli.rb
License: MIT
==> Dependencies
Build: pkg-config ✔, rust ✘
Required: openssl@3 ✔, python@3.11 ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 22,096 (30 days), 77,234 (90 days), 321,052 (365 days)
install-on-request: 22,064 (30 days), 77,147 (90 days), 320,836 (365 days)
build-error: 50 (30 days)
riweston commented 1 month ago

Thanks for raising this @sergeibelov113! The tool manipulates the config file azure-cli uses so there must be some bug when it tries to make the change. I'll investigate and report back 👍