Azure / autorest.az

Azure CLI Code Generator
MIT License
22 stars 20 forks source link

Unable to build a model: Cannon deserialize as [MicrosoftGraphRecipient] an object of type <class 'dict'> #805

Closed jobala closed 3 years ago

jobala commented 3 years ago

command

mg mail user create-message --user-id "sender@domain.org"  --subject "Yo" --body content="Message" content-type="application/text" --to-recipient '{"emailAddress":{"address":"garth@contoso.com"}}'

yml file

https://github.com/microsoftgraph/msgraph-cli/blob/task%2Fsamples/open-api-docs/v1_0/Mail.yml

error

The command failed with an unexpected error. Here is the traceback:
Unable to build a model: Cannot deserialize as [MicrosoftGraphRecipient] an object of type <class 'dict'>, DeserializationError: Cannot deserialize as [MicrosoftGraphRecipient] an object of type <class 'dict'>
Traceback (most recent call last):
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 620, in body
    data = deserializer._deserialize(data_type, data)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 1442, in _deserialize
    value = self.deserialize_data(raw_value, attr_desc['type'])
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 1618, in deserialize_data
    return self.deserialize_type[iter_type](data, data_type[1:-1])
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 1645, in deserialize_iter
    raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(
msrest.exceptions.DeserializationError: Cannot deserialize as [MicrosoftGraphRecipient] an object of type <class 'dict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 660, in execute
    raise ex
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 723, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 716, in _run_job
    six.reraise(*sys.exc_info())
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/six.py", line 703, in reraise
    raise value
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 694, in _run_job
    result = cmd_copy(params)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 331, in __call__
    return self.handler(*args, **kwargs)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azure/cli/core/__init__.py", line 811, in default_command_handler
    return op(**command_args)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azext_mail/generated/custom.py", line 125, in mail_user_create_message
    return client.create_messages(user_id=user_id,
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/azext_mail/vendored_sdks/mail/operations/_users_operations.py", line 723, in create_messages
    body_content = self._serialize.body(body, 'MicrosoftGraphMessage')
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 622, in body
    raise_with_traceback(
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 620, in body
    data = deserializer._deserialize(data_type, data)
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 1442, in _deserialize
    value = self.deserialize_data(raw_value, attr_desc['type'])
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 1618, in deserialize_data
    return self.deserialize_type[iter_type](data, data_type[1:-1])
  File "/Users/jobala/.local/share/virtualenvs/msgraph-cli-experiment-PdxeK3ZY/lib/python3.9/site-packages/msrest/serialization.py", line 1645, in deserialize_iter
    raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(
msrest.exceptions.SerializationError: Unable to build a model: Cannot deserialize as [MicrosoftGraphRecipient] an object of type <class 'dict'>, DeserializationError: Cannot deserialize as [MicrosoftGraphRecipient] an object of type <class 'dict'>
jobala commented 3 years ago

Fixed by passing a list instead of a string to --to-recipient