Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

Failure of `az spring connection list --app app-name` with `'Namespace' object has no attribute 'opt_out_list'` #29001

Open nevenc opened 5 months ago

nevenc commented 5 months ago

Describe the bug

I am trying to list a connection for Azure Spring Apps, through Azure CLI 2.60.0.

It seems we introduced a bug in Azure CLI 2.60.0, because this works in Azure CLI 2.59.0

Related command

az spring connection list --app catalog-service

Errors

'Namespace' object has no attribute 'opt_out_list'

Issue script & Debug output

cli.knack.cli: Command arguments: ['spring', 'connection', 'list', '--app', 'catalog-service', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f2264309160>, <function OutputProducer.on_global_arguments at 0x7f2264223ca0>, <function CLIQuery.on_global_arguments at 0x7f22641bb280>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'spring': ['azure.cli.command_modules.serviceconnector', 'azext_serviceconnector_passwordless', 'azext_spring'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: serviceconnector 0.305 24 354 cli.azure.cli.core: Total (1) 0.305 24 354 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: ai-examples 0.089 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples cli.azure.cli.core: serviceconnector-passwordless 0.084 17 24 /home/neven/.azure/cliextensions/serviceconnector-passwordless cli.azure.cli.core: spring 0.300 46 206 /home/neven/.azure/cliextensions/spring cli.azure.cli.core: Total (3) 0.474 64 231
cli.azure.cli.core: Loaded 70 groups, 561 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : spring connection list cli.azure.cli.core: Command table: spring connection list cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f2263669700>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/neven/.azure/commands/2024-05-21.19-40-06.spring_connection_list.4102.log'. az_command_data_logger: command args: spring connection list --app {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7f2263611310>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7f226363a310>, <function register_cache_arguments..add_cache_arguments at 0x7f22635da1f0>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f2264223d30>, <function CLIQuery.handle_query_parameter at 0x7f22641bb310>, <function register_ids_argument..parse_ids_arguments at 0x7f22635da160>] cli.azure.cli.core.azclierror: Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/invocation.py", line 113, in _validation self._validate_arg_level(parsed_ns) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 898, in _validate_arg_level validator(**self._build_kwargs(validator, ns)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 875, in validate_params _validate_and_apply(validate_list_params, apply_list_params) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 870, in _validate_and_apply arg_values = intelligent_experience(cmd, namespace, missing_args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 307, in intelligent_experience if opt_out_auth(namespace): File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 289, in opt_out_auth opt_out_list = namespace.opt_out_list AttributeError: 'Namespace' object has no attribute 'opt_out_list'

cli.azure.cli.core.azclierror: 'Namespace' object has no attribute 'opt_out_list' az_command_data_logger: 'Namespace' object has no attribute 'opt_out_list' cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f2263669940>] az_command_data_logger: exit code: 2 cli.main: Command ran in 1.067 seconds (init: 0.188, invoke: 0.879) telemetry.main: Begin splitting cli events and extra events, total events: 1 telemetry.client: Accumulated 0 events. Flush the clients. telemetry.main: Finish splitting cli events and extra events, cli events: 1 telemetry.save: Save telemetry record of length 3838 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/init.py /home/neven/.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.

Expected behavior

I am expected to show the list of all service connectors as in previous versions of Azure CLI.

Environment Summary

azure-cli 2.60.0 *

core 2.60.0 * telemetry 1.1.0

Extensions: ai-examples 0.2.5 ml 2.25.1 serviceconnector-passwordless 2.0.2 spring 1.24.3 ssh 2.0.3

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.0b2

Python location '/usr/bin/python3.9' Extensions directory '/home/neven/.azure/cliextensions' Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.19 (main, Mar 28 2024, 18:56:59) [GCC 11.2.0]

Additional context

Here is related issue.

I believe this commit introduced the error.

azure-client-tools-bot-prd[bot] commented 5 months ago

Hi @nevenc,

2.60.0 is not the latest Azure CLI(2.61.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

azure-client-tools-bot-prd[bot] commented 5 months ago
Hi @nevenc Find similar issue https://github.com/Azure/azure-cli/issues/28865.
Issue title Failure of az containerapp connection create postgres with 'Namespace' object has no attribute 'opt_out_list'
Create time 2024-05-01
Comment number 0

Please confirm if this resolves your issue.

yonzhan commented 5 months ago

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

nevenc commented 5 months ago

I just tried upgrading Azure CLI to 2.61.0 and it seems that fixed it!

nevenc commented 5 months ago

Azure CLI 2.61.0 is not available in Cloud Shell just yet. It will be available on the next build of Cloud Shell. Hopefully, soon!

nevenc commented 5 months ago

az upgrade does not work on Azure Cloud Shell

az upgrade
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Your current Azure CLI version is 2.60.0. Latest version available is 2.61.0.
Please check the release notes first: https://docs.microsoft.com/cli/azure/release-notes-azure-cli
Do you want to continue? (Y/n): y
Not able to upgrade automatically. Instructions can be found at https://aka.ms/doc/InstallAzureCli
CLI upgrade failed or aborted.
nevenc commented 5 months ago

I guess I need to wait for the next build: https://learn.microsoft.com/en-us/cli/azure/update-azure-cli

If you're running the Azure CLI through Azure Cloud Shell, you're most likely already using the most recent Azure CLI install. If not due to cases like ad-hoc release of a minor bug fix version, you need to wait for the next build of Azure Cloud Shell as az upgrade isn't supported in Azure Cloud Shell.
xfz11 commented 5 months ago

Fixed in https://github.com/Azure/azure-cli/pull/28918. Hi @nevenc, CLI in Cloud Shell will take about 1 week to update after the general release.