Repository: microsoft/botbuilder-python

Issue:
Python 81.skills-skilldialog throwing error: [on_turn_error] unhandled error: Cannot deserialize content-type: text/plain
## Sample information
1. Sample type: \samples\
2. Sample language: python
3. Sample name: 81.skills-skilldialog

## Describe the bug
When you run the sample as per the instructions, the skill bot is throwing the following error:

======== Running on http://localhost:39783 ========
(Press CTRL+C to quit)

 [on_turn_error] unhandled error: Cannot deserialize content-type: text/plain
Traceback (most recent call last):
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/bot_adapter.py", line 128, in run_pipeline
    context, callback
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
    return await self.receive_activity_internal(context, callback)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
    return await callback(context)
  File "/Users/tim/Documents/Sourcetree/BotBuilderSamples/samples/python/81.skills-skilldialog/dialog-skill-bot/bots/skill_bot.py", line 21, in on_turn
    self._conversation_state.create_property("DialogState"),
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/dialog_extensions.py", line 68, in run_dialog
    result = await dialog_context.begin_dialog(dialog.id)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/dialog_context.py", line 91, in begin_dialog
    return await dialog.begin_dialog(self, options)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/component_dialog.py", line 67, in begin_dialog
    turn_result = await self.on_begin_dialog(inner_dc, options)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/component_dialog.py", line 221, in on_begin_dialog
    return await inner_dc.begin_dialog(self.initial_dialog_id, options)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/dialog_context.py", line 91, in begin_dialog
    return await dialog.begin_dialog(self, options)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/waterfall_dialog.py", line 65, in begin_dialog
    return await self.run_step(dialog_context, 0, DialogReason.BeginCalled, None)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/waterfall_dialog.py", line 156, in run_step
    return await self.on_step(step_context)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/dialogs/waterfall_dialog.py", line 132, in on_step
    return await self._steps[step_context.index](step_context)
  File "/Users/tim/Documents/Sourcetree/BotBuilderSamples/samples/python/81.skills-skilldialog/dialog-skill-bot/dialogs/activity_router_dialog.py", line 50, in process_activity
    return await self._on_event_activity(step_context)
  File "/Users/tim/Documents/Sourcetree/BotBuilderSamples/samples/python/81.skills-skilldialog/dialog-skill-bot/dialogs/activity_router_dialog.py", line 77, in _on_event_activity
    return await self._begin_get_weather(step_context)
  File "/Users/tim/Documents/Sourcetree/BotBuilderSamples/samples/python/81.skills-skilldialog/dialog-skill-bot/dialogs/activity_router_dialog.py", line 156, in _begin_get_weather
    get_weather_message, get_weather_message, InputHints.ignoring_input,
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/turn_context.py", line 174, in send_activity
    result = await self.send_activities([activity_or_text])
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/turn_context.py", line 226, in send_activities
    return await self._emit(self._on_send_activities, output, logic())
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/turn_context.py", line 304, in _emit
    return await logic
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/turn_context.py", line 221, in logic
    responses = await self.adapter.send_activities(self, output)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/bot_framework_adapter.py", line 729, in send_activities
    raise error
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botbuilder/core/bot_framework_adapter.py", line 715, in send_activities
    activity.conversation.id, activity.reply_to_id, activity
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/botframework/connector/aio/operations_async/_conversations_operations_async.py", line 529, in reply_to_activity
    request, stream=False, **operation_config
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/async_client.py", line 115, in async_send
    pipeline_response = await self.config.pipeline.run(request, **kwargs)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/async_abc.py", line 159, in run
    return await first_node.send(pipeline_request, **kwargs)  # type: ignore
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/async_abc.py", line 79, in send
    response = await self.next.send(request, **kwargs)  # type: ignore
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/async_requests.py", line 106, in send
    return await self.next.send(request, **kwargs)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/async_abc.py", line 84, in send
    self._policy.on_response(request, response, **kwargs)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/universal.py", line 252, in on_response
    http_response.headers
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/universal.py", line 226, in deserialize_from_http_generics
    return cls.deserialize_from_text(body_bytes, content_type)
  File "/Users/tim/.pyenv/versions/bot379/lib/python3.7/site-packages/msrest/pipeline/universal.py", line 203, in deserialize_from_text
    raise DeserializationError("Cannot deserialize content-type: {}".format(content_type))
msrest.exceptions.DeserializationError: Cannot deserialize content-type: text/plain



## To Reproduce
Steps to reproduce the behavior:
1. Run the root & skill bots as per the instructions from the sample readme
2. Start the bot framework emulator & connect
3. Choose the DialogSkillBot
4. Enter activity 3

## Expected behavior
Error not returned




Discussion:
As requested by @v-kydela I tried commenting out the two calls to send_activity_trace in the skillbot & re-running the test - [here](https://github.com/microsoft/BotBuilder-Samples/blob/main/samples/python/81.skills-skilldialog/dialog-skill-bot/dialogs/activity_router_dialog.py#L44-L47) & [here](https://github.com/microsoft/BotBuilder-Samples/blob/main/samples/python/81.skills-skilldialog/dialog-skill-bot/skill_adapter_with_error_handler.py#L57-L62).

The error still happens.
Hello @wonboyn, I couldn't reproduce this issue using v4.11.0 of the botbuilder packages and the latest version of this sample. I tried with clean installations of Python 3.7.9 and 3.8.7

With those configurations, the sample runs as expected. But I noticed that there's an error in the requirements.txt given that it doesn't include neither botbuilder-dialogs nor botbuilder-ai, which are necessary for the skill bot to run. There is a possibility that you might've been running the sample with those packages outdated. Could you please double check the version of all botbuilder packages that you used?

Please let me know if you keep encountering this problem.
Hi @axelsrz 

I am using python v3.7.9 & botbuilder v4.11.0 - albeit with pyenv:

% pip list
Package                               Version
------------------------------------- ---------
adal                                  1.2.1
aiohttp                               3.6.2
aiounittest                           1.4.0
async-timeout                         3.0.1
attrs                                 20.3.0
azure-cognitiveservices-language-luis 0.2.0
azure-common                          1.1.26
Babel                                 2.7.0
botbuilder-ai                         4.11.0
botbuilder-core                       4.11.0
botbuilder-dialogs                    4.11.0
botbuilder-integration-aiohttp        4.11.0
botbuilder-schema                     4.11.0
botframework-connector                4.11.0
certifi                               2020.12.5
cffi                                  1.14.4
chardet                               3.0.4
cryptography                          2.8
datatypes-date-time                   1.0.0a2
datedelta                             1.3
emoji                                 0.6.0
grapheme                              0.6.0
idna                                  2.10
isodate                               0.6.0
jsonpickle                            1.2
msal                                  1.2.0
msrest                                0.6.10
msrestazure                           0.6.4
multidict                             4.7.6
multipledispatch                      0.6.0
oauthlib                              3.1.0
pip                                   20.1.1
pycparser                             2.20
PyJWT                                 1.5.3
python-dateutil                       2.8.1
pytz                                  2020.4
recognizers-text                      1.0.2a2
recognizers-text-choice               1.0.2a2
recognizers-text-date-time            1.0.2a2
recognizers-text-number               1.0.2a2
recognizers-text-number-with-unit     1.0.2a2
regex                                 2019.8.19
requests                              2.23.0
requests-oauthlib                     1.3.0
setuptools                            47.1.0
six                                   1.15.0
typing-extensions                     3.7.4.3
urllib3                               1.25.11
wrapt                                 1.12.1
yarl                                  1.6.3

Thanks for the reply @wonboyn. Running the scenarios again I realized that in my previous test I was using Python 3.7.9 and 3.8.7 only for the Skill bot, the parent was always running in 3.8.7. After testing running the parent in 3.7.9 I was able to reproduce.

This looks like a product issue (I will transfer this to the python repo in the following days) and we should fix it in the course of our current release cycle - 4.12.0.
In the meantime, a workaround would be to run at least your parent bot in 3.8 (you can leave the skill in 3.7 or 3.8).

Let me know if you have further questions.
@axelsrz Is this still on your radar?

Resolving patch:
diff --git a/libraries/botbuilder-integration-aiohttp/setup.py b/libraries/botbuilder-integration-aiohttp/setup.py
--- a/libraries/botbuilder-integration-aiohttp/setup.py
+++ b/libraries/botbuilder-integration-aiohttp/setup.py
@@ -9,6 +9,7 @@
     "botbuilder-schema==4.12.0",
     "botframework-connector==4.12.0",
     "botbuilder-core==4.12.0",
+    "yarl<=1.4.2",
     "aiohttp==3.6.2",
 ]
 


Test patch: