Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
383 stars 1.23k forks source link

az postgress up - option values must be strings #6293

Open Andomeda83 opened 1 year ago

Andomeda83 commented 1 year ago

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az postgres up Extension Name: db-up. Version: 0.2.7.

Errors:

option values must be strings

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

I rand the above command, but noticed it created the resource in a location I didn't want.

So I set my default location via az configure --defaults location=uksouth and got the above when re-running the command.

I've now unset the default with az config unset defaults.location but I still get the same error.

Expected Behavior

az postgres up to work but in the location I set, i.e. uksouth.

Environment Summary

Linux-5.4.0-1107-azure-x86_64-with-glibc2.35 (Cloud Shell), CBL-Mariner/Linux
Python 3.9.14
Installer: RPM

azure-cli 2.48.1

Extensions:
ai-examples 0.2.5
db-up 0.2.7
ml 2.15.1
ssh 1.1.6

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Additional Context

yonzhan commented 1 year ago

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

evelyn-ys commented 1 year ago

Have you try manually specify --location?

Andomeda83 commented 1 year ago

Sorry, I should've mentioned that originally. I have, and it's the same error:

[ ~ ]$ az postgres up -l "uksouth"
option values must be strings
[ ~ ]$ az postgres up --location "uksouth"
option values must be strings
evelyn-ys commented 1 year ago

Can you share the full debug log with az postgres up -l uksouth --debug?

Andomeda83 commented 1 year ago

Sure, see below.

Looks like it's looking for the resource group from the first time I ran the command and subsequently deleted because the db was in the wrong location.

I can clearly override that, or recreate the group, but why is it trying to re-use that? Is it set somewhere and is there a "clear" command?

Thanks for your help

[ ~ ]$ az postgres up -l uksouth --debug
cli.knack.cli: Command arguments: ['postgres', 'up', '-l', 'uksouth', '--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 0x7fb95af08160>, <function OutputProducer.on_global_arguments at 0x7fb95ae27b80>, <function CLIQuery.on_global_arguments at 0x7fb95adb7160>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'postgres': ['azure.cli.command_modules.rdbms', 'azext_db_up']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: rdbms                     0.213        55       230
cli.azure.cli.core: Total (1)                 0.213        55       230
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.061         1         1  /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.knack.cli: Event: CommandLoader.OnLoadCommandTable []
cli.azure.cli.core: db-up                     0.003         3         8  /home/Andomeda83/.azure/cliextensions/db-up
cli.azure.cli.core: Total (2)                 0.065         4         9  
cli.azure.cli.core: Loaded 57 groups, 239 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : postgres up
cli.azure.cli.core: Command table: postgres up
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fb95a05a280>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/Andomeda83/.azure/commands/2023-05-18.08-04-12.postgres_up.203.log'.
az_command_data_logger: command args: postgres up -l {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fb95a002e50>]
cli.knack.cli: Event: CommandLoader.OnLoadArguments []
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fb95a035040>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7fb95a03de50>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fb95ae27c10>, <function CLIQuery.handle_query_parameter at 0x7fb95adb71f0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7fb95a03ddc0>]
az_command_data_logger: extension name: db-up
az_command_data_logger: extension version: 0.2.7
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ResourceManagementClient
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2190
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: MSIAuthenticationWrapper.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2190
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: Normalize expires_on: '1684398558' -> 1684398558
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/1bdc9c7e-853a-4617-bd06-705e51752e2a/resourcegroups/group8237452510?api-version=2022-09-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': '92f77f64-f552-11ed-9d35-f2fd9b9695a9'
cli.azure.cli.core.sdk.policies:     'CommandName': 'postgres up'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '-l --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.48.1 (RPM) azsdk-python-azure-mgmt-resource/22.0.0 Python/3.9.14 (Linux-5.4.0-1107-azure-x86_64-with-glibc2.35) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/1bdc9c7e-853a-4617-bd06-705e51752e2a/resourcegroups/group8237452510?api-version=2022-09-01 HTTP/1.1" 404 107
cli.azure.cli.core.sdk.policies: Response status: 404
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'x-ms-failure-cause': 'gateway'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-reads': '11998'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '2308ec5f-9b3c-4ff3-8c48-bc972a057bc5'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '2308ec5f-9b3c-4ff3-8c48-bc972a057bc5'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'WESTEUROPE:20230518T080412Z:2308ec5f-9b3c-4ff3-8c48-bc972a057bc5'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'Date': 'Thu, 18 May 2023 08:04:12 GMT'
cli.azure.cli.core.sdk.policies:     'Content-Length': '107'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"ResourceGroupNotFound","message":"Resource group 'group8237452510' could not be found."}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/invocation.py", line 111, in _validation
    self._validate_cmd_level(parsed_ns, cmd_validator)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 849, in _validate_cmd_level
    cmd_validator(**self._build_kwargs(cmd_validator, ns))
  File "/home/Andomeda83/.azure/cliextensions/db-up/azext_db_up/_validators.py", line 26, in <lambda>
    return lambda cmd, namespace: _process_db_up_namespace(cmd, namespace, db_type=db_type)
  File "/home/Andomeda83/.azure/cliextensions/db-up/azext_db_up/_validators.py", line 57, in _process_db_up_namespace
    set_config_value(db_type, 'group', namespace.resource_group_name)
  File "/home/Andomeda83/.azure/cliextensions/db-up/azext_db_up/util.py", line 48, in set_config_value
    DB_CONFIG.set_value(config_section, option, value)
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/config.py", line 161, in set_value
    self._config_file_chain[-1].set_value(section, option, value)
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/config.py", line 239, in set_value
    config.set(section, option, value)
  File "/usr/lib/python3.9/configparser.py", line 1203, in set
    self._validate_value_types(option=option, value=value)
  File "/usr/lib/python3.9/configparser.py", line 1188, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings

cli.azure.cli.core.azclierror: option values must be strings
az_command_data_logger: option values must be strings
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fb95a05a4c0>]
az_command_data_logger: exit code: 2
cli.__main__: Command ran in 0.623 seconds (init: 0.111, invoke: 0.512)
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 3544 in cache
telemetry.check: Returns Positive.
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/Andomeda83/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.