Azure / azure-cli-extensions

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

Why is the `--attachments` option required when executing the `az communication email send` command? #7238

Open tatsuyaHello opened 9 months ago

tatsuyaHello commented 9 months ago

Describe the bug

The --attachments option is now required when executing the az communication email send command.

image

I understand that the communication version I am using ("1.8.0b1") is the preview, so updates run constantly based on feedback. https://learn.microsoft.com/en-us/cli/azure/reference-types-and-status#what-is-reference-status

image

However, I find it too odd to make the --attachments option mandatory.

Related command

az communication email send

Errors

ERROR: (BadRequest) Request body validation error. See property 'attachments'
Code: BadRequest
Message: Request body validation error. See property 'attachments'

Issue script & Debug output

cli.knack.cli: Command arguments: ['communication', 'email', 'send', '--connection-string', 'endpoint=<mask>', '--sender', '<mask>', '--bcc', '<mask>', '--subject', 'test mail', '--html', 'hoge', '--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 0x7f863ad6e1f0>, <function OutputProducer.on_global_arguments at 0x7f863ac87d30>, <function CLIQuery.on_global_arguments at 0x7f863ac1f310>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'communication': ['azext_communication']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: Total (0)                 0.000         0         0
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.190         1         1  /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: communication             0.093        18        51  /home/tatsuya/.azure/cliextensions/communication
cli.azure.cli.core: Total (2)                 0.283        19        52  
cli.azure.cli.core: Loaded 19 groups, 52 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : communication email send
cli.azure.cli.core: Command table: communication email send
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f863a0c55e0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/tatsuya/.azure/commands/2024-02-01.11-25-47.communication_email_send.4582.log'.
az_command_data_logger: command args: communication email send --connection-string {} --sender {} --bcc {} --subject {} --html {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f863a03a040>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f863a03a280>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f863a05d160>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f863ac87dc0>, <function CLIQuery.handle_query_parameter at 0x7f863ac1f3a0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f863a05d0d0>]
az_command_data_logger: extension name: communication
az_command_data_logger: extension version: 1.8.0b1
urllib3.connectionpool: Starting new HTTPS connection (1): acs-sample-tyamamura.japan.communication.azure.com:443
urllib3.connectionpool: https://acs-sample-tyamamura.japan.communication.azure.com:443 "POST /emails:send?api-version=2023-03-31 HTTP/1.1" 400 148
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/tatsuya/.azure/cliextensions/communication/azext_communication/manual/custom.py", line 403, in communication_email_send
    return client.begin_send(message)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/home/tatsuya/.azure/cliextensions/communication/azure/communication/email/_email_client.py", line 179, in begin_send
    return self._generated_client.email.begin_send(message=message, **kwargs)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/home/tatsuya/.azure/cliextensions/communication/azure/communication/email/_generated/operations/_operations.py", line 503, in begin_send
    raw_result = self._send_initial(  # type: ignore
  File "/home/tatsuya/.azure/cliextensions/communication/azure/communication/email/_generated/operations/_operations.py", line 240, in _send_initial
    raise HttpResponseError(response=response)
azure.core.exceptions.HttpResponseError: (BadRequest) Request body validation error. See property 'attachments'
Code: BadRequest
Message: Request body validation error. See property 'attachments'

cli.azure.cli.core.azclierror: (BadRequest) Request body validation error. See property 'attachments'
Code: BadRequest
Message: Request body validation error. See property 'attachments'
az_command_data_logger: (BadRequest) Request body validation error. See property 'attachments'
Code: BadRequest
Message: Request body validation error. See property 'attachments'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f863a0c5820>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.852 seconds (init: 0.289, invoke: 0.563)
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 3749 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/tatsuya/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

I think --attachments is optional command.

Environment Summary

azure-cli                         2.56.0

core                              2.56.0
telemetry                          1.1.0

Extensions:
ai-examples                        0.2.5
communication                    1.8.0b1
ml                                2.22.0
ssh                                2.0.2

Dependencies:
msal                            1.24.0b2
azure-mgmt-resource             23.1.0b2

Additional context

No response

yonzhan commented 9 months ago

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

blagar2 commented 8 months ago

We got the same problem has tatsuyaHello. on version 1.8.0b1. There was no problem in the version extension "communication": "1.6.1",