prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Teams Task Module - Deserialization Error on Teams mobile app for iOS
  ## Version
  botbuilder-integration-aiohttp 4.14.0
  Python 3.8.6 
  
  ## Describe the bug
  Error when loading Task Module on iOS iOS 14.8.1 / MS Teams v3.20.0
  
  ## To Reproduce
  1. Deploy [sample bot 54.teams-task-module](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/54.teams-task-module) 
  2. Say hello and click on _Adaptive Card_ button
  3. Deserialization Error when on iOS iOS 14.8.1 / Microsoft Teams v3.20.0
  ![image](https://user-images.githubusercontent.com/4013036/146412591-61399a75-d3d3-4eb6-a0ec-36ffa3cac54c.png)
  
  ## Traceback
  _(file locations prefix intentionally removed)_
  ```
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1293, in _deserialize
      found_value = key_extractor(attr, attr_desc, data)
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1064, in rest_key_extractor
      return working_data.get(key)
  AttributeError: 'str' object has no attribute 'get'
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
    File "test_teams_task/env/lib/site-packages/botbuilder/core/bot_adapter.py", line 129, in run_pipeline
      context, callback
    File "test_teams_task/env/lib/site-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
      return await self.receive_activity_internal(context, callback)
    File "test_teams_task/env/lib/site-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
      return await callback(context)
    File "test_teams_task/env/lib/site-packages/botbuilder/core/activity_handler.py", line 78, in on_turn
      invoke_response = await self.on_invoke_activity(turn_context)
    File "test_teams_task/env/lib/site-packages/botbuilder/core/teams/teams_activity_handler.py", line 155, in on_invoke_activity
      TaskModuleRequest, turn_context.activity.value
    File "test_teams_task/env/lib/site-packages/botbuilder/core/serializer_helper.py", line 28, in deserializer_helper
      return deserializer(msrest_cls.__name__, dict_to_deserialize)
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1233, in __call__
      return self._deserialize(target_obj, data)
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1299, in _deserialize
      value = self.deserialize_data(raw_value, attr_desc['type'])
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1468, in deserialize_data
      return self._deserialize(obj_type, data)
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1303, in _deserialize
      raise_with_traceback(DeserializationError, msg, err)
    File "test_teams_task/env/lib/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
      raise error.with_traceback(exc_traceback)
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1293, in _deserialize
      found_value = key_extractor(attr, attr_desc, data)
    File "test_teams_task/env/lib/site-packages/msrest/serialization.py", line 1064, in rest_key_extractor
      return working_data.get(key)
  msrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'
  ```
  
  ## Expected behavior
  This sample bot raises no error when interacting on the following platforms:
  - Windows 10 (Desktop app, Firefox, Chrome)
  - macOS (Chrome)
  - Android (Mobile app)
  ![image](https://user-images.githubusercontent.com/4013036/146413680-7bc42c4d-9876-4d18-9a61-7b94b4a5cccb.png)
  
  It was possible to interact with Task Module on iOS iOS 14.8.1 / Microsoft Teams v3.20.0 when deploying these samples (python not included):
  https://docs.microsoft.com/en-us/samples/officedev/microsoft-teams-samples/ms-teams-task-sample/
  
  ## Additional context
  Initially the error was detected on a bot in production currently deployed in Azure. Since the error message is the same when running [bot sample 54.teams-task-module](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/54.teams-task-module), for the sake of repro we can take this example. 
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `libraries/botbuilder-core/botbuilder/core/serializer_helper.py`
  Content:
  ```
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License.
  3 
  4 from inspect import getmembers
  5 from typing import Type
  6 from enum import Enum
  7 
  8 from msrest.serialization import Model, Deserializer, Serializer
  9 
  10 import botbuilder.schema as schema
  11 import botbuilder.schema.teams as teams_schema
  12 
  13 DEPENDICIES = [
  14     schema_cls
  15     for key, schema_cls in getmembers(schema)
  16     if isinstance(schema_cls, type) and issubclass(schema_cls, (Model, Enum))
  17 ]
  18 DEPENDICIES += [
  19     schema_cls
  20     for key, schema_cls in getmembers(teams_schema)
  21     if isinstance(schema_cls, type) and issubclass(schema_cls, (Model, Enum))
  22 ]
  23 DEPENDICIES_DICT = {dependency.__name__: dependency for dependency in DEPENDICIES}
  24 
  25 
  26 def deserializer_helper(msrest_cls: Type[Model], dict_to_deserialize: dict) -> Model:
  27     deserializer = Deserializer(DEPENDICIES_DICT)
  28     return deserializer(msrest_cls.__name__, dict_to_deserialize)
  29 
  30 
  31 def serializer_helper(object_to_serialize: Model) -> dict:
  32     if object_to_serialize is None:
  33         return None
  34 
  35     serializer = Serializer(DEPENDICIES_DICT)
  36     # pylint: disable=protected-access
  37     return serializer._serialize(object_to_serialize)
  38
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/libraries/botbuilder-core/botbuilder/core/serializer_helper.py b/libraries/botbuilder-core/botbuilder/core/serializer_helper.py
  --- a/libraries/botbuilder-core/botbuilder/core/serializer_helper.py
  +++ b/libraries/botbuilder-core/botbuilder/core/serializer_helper.py
  @@ -1,6 +1,6 @@
   # Copyright (c) Microsoft Corporation. All rights reserved.
   # Licensed under the MIT License.
  -
  +from copy import copy
   from inspect import getmembers
   from typing import Type
   from enum import Enum
  @@ -25,6 +25,9 @@
   
   def deserializer_helper(msrest_cls: Type[Model], dict_to_deserialize: dict) -> Model:
       deserializer = Deserializer(DEPENDICIES_DICT)
  +    _clean_data_for_serialization(
  +        deserializer.dependencies[msrest_cls.__name__], dict_to_deserialize
  +    )
       return deserializer(msrest_cls.__name__, dict_to_deserialize)
   
   
  @@ -35,3 +38,21 @@
       serializer = Serializer(DEPENDICIES_DICT)
       # pylint: disable=protected-access
       return serializer._serialize(object_to_serialize)
  +
  +
  +def _clean_data_for_serialization(msrest_cls: Type[Model], dict_to_deserialize: dict):
  +    # pylint: disable=protected-access
  +    # Clean channel response of empty strings for expected objects.
  +    if not isinstance(dict_to_deserialize, dict):
  +        return
  +    serialization_model = copy(msrest_cls._attribute_map)
  +    for key, value in msrest_cls._attribute_map.items():
  +        if key != value["key"]:
  +            serialization_model[value["key"]] = value
  +    for prop, prop_value in dict_to_deserialize.items():
  +        if (
  +            prop in serialization_model
  +            and serialization_model[prop]["type"] in DEPENDICIES_DICT
  +            and not prop_value
  +        ):
  +            dict_to_deserialize[prop] = None
  
verification_info: {"golden_diff": "diff --git a/libraries/botbuilder-core/botbuilder/core/serializer_helper.py b/libraries/botbuilder-core/botbuilder/core/serializer_helper.py\n--- a/libraries/botbuilder-core/botbuilder/core/serializer_helper.py\n+++ b/libraries/botbuilder-core/botbuilder/core/serializer_helper.py\n@@ -1,6 +1,6 @@\n # Copyright (c) Microsoft Corporation. All rights reserved.\n # Licensed under the MIT License.\n-\n+from copy import copy\n from inspect import getmembers\n from typing import Type\n from enum import Enum\n@@ -25,6 +25,9 @@\n \n def deserializer_helper(msrest_cls: Type[Model], dict_to_deserialize: dict) -> Model:\n     deserializer = Deserializer(DEPENDICIES_DICT)\n+    _clean_data_for_serialization(\n+        deserializer.dependencies[msrest_cls.__name__], dict_to_deserialize\n+    )\n     return deserializer(msrest_cls.__name__, dict_to_deserialize)\n \n \n@@ -35,3 +38,21 @@\n     serializer = Serializer(DEPENDICIES_DICT)\n     # pylint: disable=protected-access\n     return serializer._serialize(object_to_serialize)\n+\n+\n+def _clean_data_for_serialization(msrest_cls: Type[Model], dict_to_deserialize: dict):\n+    # pylint: disable=protected-access\n+    # Clean channel response of empty strings for expected objects.\n+    if not isinstance(dict_to_deserialize, dict):\n+        return\n+    serialization_model = copy(msrest_cls._attribute_map)\n+    for key, value in msrest_cls._attribute_map.items():\n+        if key != value[\"key\"]:\n+            serialization_model[value[\"key\"]] = value\n+    for prop, prop_value in dict_to_deserialize.items():\n+        if (\n+            prop in serialization_model\n+            and serialization_model[prop][\"type\"] in DEPENDICIES_DICT\n+            and not prop_value\n+        ):\n+            dict_to_deserialize[prop] = None\n", "issue": "Teams Task Module - Deserialization Error on Teams mobile app for iOS\n## Version\r\nbotbuilder-integration-aiohttp 4.14.0\r\nPython 3.8.6 \r\n\r\n## Describe the bug\r\nError when loading Task Module on iOS iOS 14.8.1 / MS Teams v3.20.0\r\n\r\n## To Reproduce\r\n1. Deploy [sample bot 54.teams-task-module](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/54.teams-task-module) \r\n2. Say hello and click on _Adaptive Card_ button\r\n3. Deserialization Error when on iOS iOS 14.8.1 / Microsoft Teams v3.20.0\r\n![image](https://user-images.githubusercontent.com/4013036/146412591-61399a75-d3d3-4eb6-a0ec-36ffa3cac54c.png)\r\n\r\n## Traceback\r\n_(file locations prefix intentionally removed)_\r\n```\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1293, in _deserialize\r\n    found_value = key_extractor(attr, attr_desc, data)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1064, in rest_key_extractor\r\n    return working_data.get(key)\r\nAttributeError: 'str' object has no attribute 'get'\r\nDuring handling of the above exception, another exception occurred:\r\nTraceback (most recent call last):\r\n  File \"test_teams_task/env/lib/site-packages/botbuilder/core/bot_adapter.py\", line 129, in run_pipeline\r\n    context, callback\r\n  File \"test_teams_task/env/lib/site-packages/botbuilder/core/middleware_set.py\", line 69, in receive_activity_with_status\r\n    return await self.receive_activity_internal(context, callback)\r\n  File \"test_teams_task/env/lib/site-packages/botbuilder/core/middleware_set.py\", line 79, in receive_activity_internal\r\n    return await callback(context)\r\n  File \"test_teams_task/env/lib/site-packages/botbuilder/core/activity_handler.py\", line 78, in on_turn\r\n    invoke_response = await self.on_invoke_activity(turn_context)\r\n  File \"test_teams_task/env/lib/site-packages/botbuilder/core/teams/teams_activity_handler.py\", line 155, in on_invoke_activity\r\n    TaskModuleRequest, turn_context.activity.value\r\n  File \"test_teams_task/env/lib/site-packages/botbuilder/core/serializer_helper.py\", line 28, in deserializer_helper\r\n    return deserializer(msrest_cls.__name__, dict_to_deserialize)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1233, in __call__\r\n    return self._deserialize(target_obj, data)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1299, in _deserialize\r\n    value = self.deserialize_data(raw_value, attr_desc['type'])\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1468, in deserialize_data\r\n    return self._deserialize(obj_type, data)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1303, in _deserialize\r\n    raise_with_traceback(DeserializationError, msg, err)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/exceptions.py\", line 51, in raise_with_traceback\r\n    raise error.with_traceback(exc_traceback)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1293, in _deserialize\r\n    found_value = key_extractor(attr, attr_desc, data)\r\n  File \"test_teams_task/env/lib/site-packages/msrest/serialization.py\", line 1064, in rest_key_extractor\r\n    return working_data.get(key)\r\nmsrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'\r\n```\r\n\r\n## Expected behavior\r\nThis sample bot raises no error when interacting on the following platforms:\r\n- Windows 10 (Desktop app, Firefox, Chrome)\r\n- macOS (Chrome)\r\n- Android (Mobile app)\r\n![image](https://user-images.githubusercontent.com/4013036/146413680-7bc42c4d-9876-4d18-9a61-7b94b4a5cccb.png)\r\n\r\nIt was possible to interact with Task Module on iOS iOS 14.8.1 / Microsoft Teams v3.20.0 when deploying these samples (python not included):\r\nhttps://docs.microsoft.com/en-us/samples/officedev/microsoft-teams-samples/ms-teams-task-sample/\r\n\r\n## Additional context\r\nInitially the error was detected on a bot in production currently deployed in Azure. Since the error message is the same when running [bot sample 54.teams-task-module](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/54.teams-task-module), for the sake of repro we can take this example. \r\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nfrom inspect import getmembers\nfrom typing import Type\nfrom enum import Enum\n\nfrom msrest.serialization import Model, Deserializer, Serializer\n\nimport botbuilder.schema as schema\nimport botbuilder.schema.teams as teams_schema\n\nDEPENDICIES = [\n    schema_cls\n    for key, schema_cls in getmembers(schema)\n    if isinstance(schema_cls, type) and issubclass(schema_cls, (Model, Enum))\n]\nDEPENDICIES += [\n    schema_cls\n    for key, schema_cls in getmembers(teams_schema)\n    if isinstance(schema_cls, type) and issubclass(schema_cls, (Model, Enum))\n]\nDEPENDICIES_DICT = {dependency.__name__: dependency for dependency in DEPENDICIES}\n\n\ndef deserializer_helper(msrest_cls: Type[Model], dict_to_deserialize: dict) -> Model:\n    deserializer = Deserializer(DEPENDICIES_DICT)\n    return deserializer(msrest_cls.__name__, dict_to_deserialize)\n\n\ndef serializer_helper(object_to_serialize: Model) -> dict:\n    if object_to_serialize is None:\n        return None\n\n    serializer = Serializer(DEPENDICIES_DICT)\n    # pylint: disable=protected-access\n    return serializer._serialize(object_to_serialize)\n", "path": "libraries/botbuilder-core/botbuilder/core/serializer_helper.py"}], "after_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\nfrom copy import copy\nfrom inspect import getmembers\nfrom typing import Type\nfrom enum import Enum\n\nfrom msrest.serialization import Model, Deserializer, Serializer\n\nimport botbuilder.schema as schema\nimport botbuilder.schema.teams as teams_schema\n\nDEPENDICIES = [\n    schema_cls\n    for key, schema_cls in getmembers(schema)\n    if isinstance(schema_cls, type) and issubclass(schema_cls, (Model, Enum))\n]\nDEPENDICIES += [\n    schema_cls\n    for key, schema_cls in getmembers(teams_schema)\n    if isinstance(schema_cls, type) and issubclass(schema_cls, (Model, Enum))\n]\nDEPENDICIES_DICT = {dependency.__name__: dependency for dependency in DEPENDICIES}\n\n\ndef deserializer_helper(msrest_cls: Type[Model], dict_to_deserialize: dict) -> Model:\n    deserializer = Deserializer(DEPENDICIES_DICT)\n    _clean_data_for_serialization(\n        deserializer.dependencies[msrest_cls.__name__], dict_to_deserialize\n    )\n    return deserializer(msrest_cls.__name__, dict_to_deserialize)\n\n\ndef serializer_helper(object_to_serialize: Model) -> dict:\n    if object_to_serialize is None:\n        return None\n\n    serializer = Serializer(DEPENDICIES_DICT)\n    # pylint: disable=protected-access\n    return serializer._serialize(object_to_serialize)\n\n\ndef _clean_data_for_serialization(msrest_cls: Type[Model], dict_to_deserialize: dict):\n    # pylint: disable=protected-access\n    # Clean channel response of empty strings for expected objects.\n    if not isinstance(dict_to_deserialize, dict):\n        return\n    serialization_model = copy(msrest_cls._attribute_map)\n    for key, value in msrest_cls._attribute_map.items():\n        if key != value[\"key\"]:\n            serialization_model[value[\"key\"]] = value\n    for prop, prop_value in dict_to_deserialize.items():\n        if (\n            prop in serialization_model\n            and serialization_model[prop][\"type\"] in DEPENDICIES_DICT\n            and not prop_value\n        ):\n            dict_to_deserialize[prop] = None\n", "path": "libraries/botbuilder-core/botbuilder/core/serializer_helper.py"}]}