azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az login does not work from inside devcontainer

Open spotlesscoder opened this issue 1 year ago • 3 comments

Describe the bug

When I install the azure CLI in my devcontainer and then run az login, the Browser opens After I successfully sign in there to azure and go back to the terminal, I see the error message

The command failed with an unexpected error. Here is the traceback:
can only concatenate str (not "NoneType") to str
Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/opt/az/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/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/custom.py", line 175, in login
    selected = SubscriptionSelector(subscriptions)()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/_subscription_selector.py", line 19, in __init__
    self._format_subscription_table()
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/_subscription_selector.py", line 52, in _format_subscription_table
    'Tenant': highlight_text(self._get_tenant_string(sub), is_default)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/_subscription_selector.py", line 31, in highlight_text
    return format_styled_text((Style.HIGHLIGHT, text)) if row_is_default else text
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/style.py", line 201, in format_styled_text
    formatted_parts.append(escape_seq + raw_text)
                           ~~~~~~~~~~~^~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str

Related command

az login

Errors

see above

Issue script & Debug output

Contains too much data I am not sure whether I can share here

Expected behavior

The login works

Environment Summary

{ "azure-cli": "2.61.0", "azure-cli-core": "2.61.0", "azure-cli-telemetry": "1.1.0", "extensions": {} }

azure-cli 2.61.0

core 2.61.0 telemetry 1.1.0

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3' Extensions directory '/home/node/.azure/cliextensions'

Python (Linux) 3.11.8 (main, May 16 2024, 03:50:11) [GCC 10.2.1 20210110]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Docker image: mcr.microsoft.com/devcontainers/typescript-node:0-18

Additional context

No response

spotlesscoder avatar Jun 27 '24 16:06 spotlesscoder

Hi @spotlesscoder Find similar issue https://github.com/Azure/azure-cli/issues/16946.

Issue title A stacktrace with a disorienting message is shown for az apim api import
Create time 2021-02-16
Comment number 3

Possible solution: The error message you are seeing is similar to the one in the old issue. In the old issue, the error message was caused by a missing value for the specificationFormat parameter. You can try specifying the specificationFormat parameter with a valid value. You can check all the valid values by running az apim api import -h.


Please confirm if this resolves your issue.

Thank you for opening this issue, we will look into it.

yonzhan avatar Jun 27 '24 16:06 yonzhan

Hi @spotlesscoder Find similar issue #16946.

Issue title A stacktrace with a disorienting message is shown for az apim api import Create time 2021-02-16 Comment number 3 Possible solution: The error message you are seeing is similar to the one in the old issue. In the old issue, the error message was caused by a missing value for the specificationFormat parameter. You can try specifying the specificationFormat parameter with a valid value. You can check all the valid values by running az apim api import -h.

Please confirm if this resolves your issue.

This is complete nonsense

spotlesscoder avatar Jun 27 '24 16:06 spotlesscoder