Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

"postgres flexible-server list" broken with 2.66.0 #30303

Open tberreis opened 2 days ago

tberreis commented 2 days ago

Describe the bug

After upgrading the CLI from 2.65.0 to 2.66.0 I'm no longer able to list my postgres flex instances. With 2.65.0 everything worked fine.

The error is reproducible with Linux, WSL and Windows.

Related command

az postgres flexible-server list

Errors

az : ERROR: The command failed with an unexpected error. Here is the traceback:
In Zeile:3 Zeichen:1
+ az postgres flexible-server list
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (ERROR: The comm... the traceback::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

ERROR: 'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/flexible_server_custom_common.py", line 49, in server_list_custom_func
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/validators.py", line 816, in check_resource_group
AttributeError: 'NoneType' object has no attribute 'replace'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

az : DEBUG: cli.knack.cli: Command arguments: ['postgres', 'flexible-server', 'list', '--debug']
In Zeile:1 Zeichen:1
+ az postgres flexible-server list --debug
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (DEBUG: cli.knac...st', '--debug']:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

DEBUG: cli.knack.cli: __init__ debug log:
Cannot enable color.
DEBUG: cli.knack.cli: Event: Cli.PreExecute []
DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x0000024333C772E0>, <function OutputProducer.on_global_arguments at 0x000002433401C040>, <function CLIQuery.on_global_arguments at 0x0000024334041440>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'postgres': ['azure.cli.command_modules.rdbms']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name                  Load Time    Groups  Commands
DEBUG: cli.azure.cli.core: rdbms                     0.625        49       204
DEBUG: cli.azure.cli.core: Total (1)                 0.625        49       204
DEBUG: cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
DEBUG: cli.azure.cli.core: Loading extensions:
DEBUG: cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
DEBUG: cli.azure.cli.core: Total (0)                 0.000         0         0  
DEBUG: cli.azure.cli.core: Loaded 49 groups, 204 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command  : postgres flexible-server list
DEBUG: cli.azure.cli.core: Command table: postgres flexible-server list
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x0000024336319940>]
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\thomas.berreis\.azure\commands\2024-11-11.12-28-23.postgres_flexible-server_list.37972.log'.
INFO: az_command_data_logger: command args: postgres flexible-server list --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x00000243363C5300>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x00000243363C53A0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x00000243363C54E0>, <function 
register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x00000243363C5580>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000002433401C0E0>, <function CLIQuery.handle_query_parameter at 0x00000243340414E0>, <function register_ids_argument.<locals>.parse_ids_arguments at 
0x00000243363C5440>]
DEBUG: cli.azure.cli.core.commands.client_factory: Getting management service client client_type=PostgreSQLManagementClient
DEBUG: cli.azure.cli.core.auth.persistence: build_persistence: location='C:\\Users\\thomas.berreis\\.azure\\msal_token_cache.bin', encrypt=True
DEBUG: cli.azure.cli.core.auth.binary_cache: load: C:\Users\thomas.berreis\.azure\msal_http_cache.bin
DEBUG: urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
DEBUG: msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/****
DEBUG: msal.authority: openid_config("https://login.microsoftonline.com/****/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/****/oauth2/v2.0/token', 
'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/****/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 
'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 
'issuer': 'https://login.microsoftonline.com/****/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 
'https://login.microsoftonline.com/****/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/****/oauth2/v2.0/devicecode', 'http_logout_supported': True, 
'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/****/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 
'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/****/kerberos', 'tenant_region_scope': 
'EU', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
DEBUG: msal.application: Broker enabled? True
DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/flexible_server_custom_common.py", line 49, in server_list_custom_func
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/validators.py", line 816, in check_resource_group
AttributeError: 'NoneType' object has no attribute 'replace'
ERROR: cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
ERROR: az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
ERROR: cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/flexible_server_custom_common.py", line 49, in server_list_custom_func
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/validators.py", line 816, in check_resource_group
AttributeError: 'NoneType' object has no attribute 'replace'
ERROR: az_command_data_logger: 'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/flexible_server_custom_common.py", line 49, in server_list_custom_func
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/rdbms/validators.py", line 816, in check_resource_group
AttributeError: 'NoneType' object has no attribute 'replace'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0000024336319BC0>]
INFO: az_command_data_logger: exit code: 1
INFO: cli.__main__: Command ran in 1.020 seconds (init: 0.242, invoke: 0.777)
INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
INFO: telemetry.client: Accumulated 0 events. Flush the clients.
INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1
INFO: telemetry.save: Save telemetry record of length 7631 in cache file under C:\Users\thomas.berreis\.azure\telemetry\20241111122824003
INFO: telemetry.main: Begin creating telemetry upload process.
INFO: telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\thomas.berreis\.azure 
C:\Users\thomas.berreis\.azure\telemetry\20241111122824003"
INFO: telemetry.process: Return from creating process 7172
INFO: telemetry.main: Finish creating telemetry upload process.

Expected behavior

List of postgres flexbile server instances (or empty list)

Environment Summary

azure-cli 2.66.0

core 2.66.0 telemetry 1.1.0

Extensions: managementpartner 0.1.3

Dependencies: msal 1.31.0 azure-mgmt-resource 23.1.1

Additional context

No response

yonzhan commented 2 days ago

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

guhcampos commented 1 day ago

I can confirm the same error on an M2 Mac installed from Homebrew:

❯ az postgres flexible-server list 
The command failed with an unexpected error. Here is the traceback:
'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/command_modules/rdbms/flexible_server_custom_common.py", line 49, in server_list_custom_func
    if (not check_resource_group(resource_group_name)):
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/lib/python3.12/site-packages/azure/cli/command_modules/rdbms/validators.py", line 816, in check_resource_group
    resource_group_name = resource_group_name.replace("'", '')
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'
nasc17 commented 1 day ago

Fix will be included in next release. Thank you so much for bringing this our attention.