Azure / azure-cli-extensions

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

InvalidArgumentValue Error in latest version of bastion extension #8004

Closed cbandera closed 1 month ago

cbandera commented 1 month ago

Describe the bug

When running az network bastion tunnel with the newest version 1.2.0 I get the following error:

ERROR: InvalidArgumentValue: Missing required field: -n

Eventhough I am passing the Bastion name via --name

Related command

az network bastion tunnel

Errors

ERROR: InvalidArgumentValue: Missing required field: -n

Issue script & Debug output

az network bastion tunnel --name "<...>" --subscription "<...>" --resource-group "<...>" --target-resource-id "<...>" --resource-port "22" --port "<...>'

DEBUG: cli.knack.cli: Command arguments: ['network', 'bastion', 'tunnel', '--debug', '--name', '', '--subscription', '', '--resource-group', '', '--target-resource-id', '/subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/', '--resource-port', '22', '--port', '60022'] DEBUG: cli.knack.cli: init debug log: Color is disabled by config. DEBUG: cli.knack.cli: Event: Cli.PreExecute [] DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x000001A0E5B49F80>, <function OutputProducer.on_global_arguments at 0x000001A0E5CC3E20>, <function CLIQuery.on_global_arguments at 0x000001A0E5D09940>] DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] DEBUG: cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_bastion'] DEBUG: cli.azure.cli.core: Loading command modules: DEBUG: cli.azure.cli.core: Name Load Time Groups Commands DEBUG: cli.azure.cli.core: network 5.495 117 354 DEBUG: cli.azure.cli.core: privatedns 0.206 14 60 DEBUG: cli.azure.cli.core: Total (2) 5.701 131 414 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: bastion 0.100 2 9 C:/Users//._29512\cliextensions\bastion DEBUG: cli.azure.cli.core: Total (1) 0.100 2 9
DEBUG: cli.azure.cli.core: Loaded 131 groups, 423 commands. DEBUG: cli.azure.cli.core: Found a match in the command table. DEBUG: cli.azure.cli.core: Raw command : network bastion tunnel DEBUG: cli.azure.cli.core: Command table: network bastion tunnel DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001A0E7F19620>] DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:/Users//._29512\commands\2024-09-20.10-00-04.network_bastion_tunnel.1760.log'. INFO: az_command_data_logger: command args: network bastion tunnel --debug --name {} --subscription {} --resource-group {} --target-resource-id {} --resource-port {} --port {} DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x000001A0E7F725C0>] DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x000001A0E7F72660>, <function register_cache_arguments..add_cache_arguments at 0x000001A0E7F727A0>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x000001A0E7F72840>] 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 0x000001A0E5CC3EC0>, <function CLIQuery.handle_query_parameter at 0x000001A0E5D099E0>, <function register_ids_argument..parse_ids_arguments at 0x000001A0E7F72700>] INFO: az_command_data_logger: extension name: bastion INFO: az_command_data_logger: extension version: 1.2.0 DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last): File "C:\Users\.venv\Lib\site-packages\azure\cli\core\aaz_command_ctx.py", line 53, in format_args self.args._schema._fmt(ctx=self, value=self.args) File "C:\Users\.venv\Lib\site-packages\azure\cli\core\aaz_arg_fmt.py", line 415, in call raise AAZInvalidArgValueError( azure.cli.core.aaz.exceptions.AAZInvalidArgValueError: InvalidArgumentValue: Missing required field: -n

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\.venv\Lib\site-packages\knack\cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\.venv\Lib\site-packages\azure\cli\core\commands__init.py", line 666, in execute raise ex File "C:\Users\.venv\Lib\site-packages\azure\cli\core\commands__init.py", line 733, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\.venv\Lib\site-packages\azure\cli\core\commands__init__.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "C:\Users\.venv\Lib\site-packages\azure\cli\core\commands\init.py", line 336, in call__ return self.handler(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\.venv\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 121, in handler return op(command_args) ^^^^^^^^^^^^^^^^^^ File "C:\Users//._29512\cliextensions\bastion\azext_bastion\custom.py", line 420, in create_bastion_tunnel bastion = Show(cli_ctx=cmd.cli_ctx)(command_args={ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\.venv\Lib\site-packages\azure\cli\core\aaz_command.py", line 155, in call__ return self._handler(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users//._29512\cliextensions\bastion\azext_bastion\aaz\latest\network\bastion_show.py", line 32, in _handler super()._handler(command_args) File "C:\Users\.venv\Lib\site-packages\azure\cli\core\aaz_command.py", line 165, in _handler self.ctx.format_args() File "C:\Users\.venv\Lib\site-packages\azure\cli\core\aaz_command_ctx.py", line 55, in format_args raise InvalidArgumentValueError(str(err)) azure.cli.core.azclierror.InvalidArgumentValueError: InvalidArgumentValue: Missing required field: -n

ERROR: cli.azure.cli.core.azclierror: InvalidArgumentValue: Missing required field: -n ERROR: az_command_data_logger: InvalidArgumentValue: Missing required field: -n DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001A0E7F198A0>] INFO: az_command_data_logger: exit code: 1 INFO: cli.main: Command ran in 7.115 seconds (init: 0.934, invoke: 6.182) 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 3847 in cache INFO: telemetry.main: Begin creating telemetry upload process. INFO: telemetry.process: Creating upload process: "C:\Users\.venv\Scripts\python.exe C:\Users\.venv\Lib\site-packages\azure\cli\telemetry__init__.py C:/Users//._29512" INFO: telemetry.process: Return from creating process INFO: telemetry.main: Finish creating telemetry upload process.

Expected behavior

The given argument --name should be sufficient to please the required -n argument

Environment Summary

azure-cli 2.64.0

core 2.64.0 telemetry 1.1.0

Extensions: bastion 1.2.0

Dependencies: msal 1.30.0 azure-mgmt-resource 23.1.1

Additional context

Downgrading to version 1.1.1 fixes the issue. Hence I suspect that #7955 has introduced the regression. Maybe by renaming the argument name to bastion_host_name? But I don't understand the code enough to confirm this, I only suspect that it might clash with other references to the old name somewhere

yonzhan commented 1 month ago

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

microsoft-github-policy-service[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub.

microsoft-github-policy-service[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @bastionsuppgithub.

shoeper commented 1 month ago

Fix for now: az extension remove -n bastion && az extension add -n bastion --version 1.1.1

markstensgaard commented 1 month ago

We also encountered this today. It took a few hours of trial-and-error between a colleague and myself to figure out that the problem was ultimately the latest bastion extension version.

alepinzon commented 1 month ago

Yes we experienced this behavior today, the temporary fix was downgrading the bastion extension from 1.2.0 to 1.1.0.

The issue was presented when we tried to connect using rdp : az network bastion rdp ...

Error: InvalidArgumentValue: Missing required field: -n

The issue #8003 is related to this.

cbandera commented 1 month ago

I can confirm that #8020 has fixed the issue and release 1.3.0 is working as expected again. Thanks @aavalang !