internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: microsoft/botbuilder-python

Issue:
[PORT] BotAdapter changes (made for custom adapter / skills compat)
> Port this change from botbuilder-dotnet/master branch:
https://github.com/microsoft/botbuilder-dotnet/pull/3148

#3147  - Added additional ContinueConversationAsync overload for custom adapters for skills compatibility.
#3146 - Move 'BotIdentityKey' const to BotAdapter and made it public.


Discussion:
Custom adapters do not currently exist for Python - just requires move 'BotIdentityKey' const to BotAdapter and made it public for parity.

Resolving patch:
diff --git a/libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_adapter.py b/libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_adapter.py
--- a/libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_adapter.py
+++ b/libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_adapter.py
@@ -138,12 +138,11 @@ async def continue_conversation(
         Sends a proactive message to a conversation. Call this method to proactively send a message to a conversation.
         Most _channels require a user to initiate a conversation with a bot before the bot can send activities
         to the user.
-        :param bot_id: The application ID of the bot. This parameter is ignored in
-        single tenant the Adpters (Console, Test, etc) but is critical to the BotFrameworkAdapter
-        which is multi-tenant aware. </param>
-        :param reference: A reference to the conversation to continue.</param>
-        :param callback: The method to call for the resulting bot turn.</param>
-        :param claims_identity:
+        :param bot_id: Unused for this override.
+        :param reference: A reference to the conversation to continue.
+        :param callback: The method to call for the resulting bot turn.
+        :param claims_identity: A ClaimsIdentity for the conversation.
+        :param audience: Unused for this override.
         """
 
         if not reference:
@@ -151,11 +150,19 @@ async def continue_conversation(
         if not callback:
             raise Exception("callback is required")
 
-        request = TurnContext.apply_conversation_reference(
-            conversation_reference_extension.get_continuation_activity(reference),
-            reference,
-        )
-        context = TurnContext(self, request)
+        if claims_identity:
+            request = conversation_reference_extension.get_continuation_activity(
+                reference
+            )
+            context = TurnContext(self, request)
+            context.turn_state[BotAdapter.BOT_IDENTITY_KEY] = claims_identity
+            context.turn_state[BotAdapter.BOT_CALLBACK_HANDLER_KEY] = callback
+        else:
+            request = TurnContext.apply_conversation_reference(
+                conversation_reference_extension.get_continuation_activity(reference),
+                reference,
+            )
+            context = TurnContext(self, request)
 
         return await self.run_pipeline(context, callback)
 


Test patch:
Repository: microsoft/botbuilder-python

Issue:
[PORT] EoC should only be handled when coming from parent in RunAsync
> Port this change from botbuilder-dotnet/master branch:
https://github.com/microsoft/botbuilder-dotnet/pull/3540

Fixes #3541 

Added check to only cancel dialogs in RunAsync when EoC comes from a parent bot (root or skill).

The issue was that this affected part of the code was being triggered when a skill responds with an EoC to a caller (EoCs are routed back to the pipeline in SkillHandler). 

This PR also applies the urn format to CallerId as per [OBI Spec](https://github.com/microsoft/botframework-obi/blob/master/protocols/botframework-activity/botframework-activity.md#bot-calling-skill)


# Changed projects
* Microsoft.Bot.Builder.Dialogs
* integration






Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py
--- a/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py
+++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py
@@ -30,7 +30,13 @@ async def run_dialog(
             if (
                 turn_context.activity.type == ActivityTypes.end_of_conversation
                 and dialog_context.stack
+                and DialogExtensions.__is_eoc_coming_from_parent(turn_context)
             ):
+                remote_cancel_text = "Skill was canceled through an EndOfConversation activity from the parent."
+                await turn_context.send_trace_activity(
+                    f"Extension {Dialog.__name__}.run_dialog", label=remote_cancel_text,
+                )
+
                 await dialog_context.cancel_all_dialogs()
             else:
                 # Process a reprompt event sent from the parent.
@@ -75,3 +81,9 @@ async def run_dialog(
             results = await dialog_context.continue_dialog()
             if results.status == DialogTurnStatus.Empty:
                 await dialog_context.begin_dialog(dialog.id)
+
+    @staticmethod
+    def __is_eoc_coming_from_parent(turn_context: TurnContext) -> bool:
+        # To determine the direction we check callerId property which is set to the parent bot
+        # by the BotFrameworkHttpClient on outgoing requests.
+        return bool(turn_context.activity.caller_id)
diff --git a/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py b/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
--- a/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
+++ b/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
@@ -97,7 +97,7 @@ async def post_activity(
             )
             activity.conversation.id = conversation_id
             activity.service_url = service_url
-            activity.caller_id = from_bot_id
+            activity.caller_id = f"urn:botframework:aadappid:{from_bot_id}"
 
             headers_dict = {
                 "Content-type": "application/json; charset=utf-8",


Test patch:
Repository: microsoft/botbuilder-python

Issue:
SkillDialog not working for non-'expected replies' scenario
## Version
4.8.0

## Describe the bug
SkillDialog won't work out of the box for non expected-replies scenarios.

## To Reproduce
Steps to reproduce the behavior:
1. Set up a root bot using skill dialog and a skill bot
2. Run both bots and initiate the SkillDialog
3. When the skill first comes back to the parent an error like the following should arise:
```
File "..path-to-botbuilder/botbuilder-python/libraries/botbuilder-dialogs/botbuilder/dialogs/skills/skill_dialog.py", line 213, in _send_to_skill
    if not 200 <= response.status <= 299:
AttributeError: 'NoneType' object has no attribute 'status'
```

## Expected behavior
The response get back to the parent without any problems

## Workaround
If the skill bot is modified to always send some content in every successful response at the route handler level, the scenario should work.

Example on how to do this for an aiohttp skill bot:
```python
#This is how a typical message handler method could look like
async def messages(req: Request) -> Response:
    # Main bot message handler.
    if "application/json" in req.headers["Content-Type"]:
        body = await req.json()
    else:
        return Response(status=415)

    activity = Activity().deserialize(body)
    auth_header = req.headers["Authorization"] if "Authorization" in req.headers else ""

    response = await ADAPTER.process_activity(activity, auth_header, BOT.on_turn)
    if response:
        return json_response(data=response.body, status=response.status)
    # THE FIX IS IN THE LINE BELOW
    return Response(status=201, body='{"foo":"bar"}'.encode("utf-8"))
```

**Alternative Workaround:** use expected replies as delivery method in the parent bot (SkillDialog).

[bug]



Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py b/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
--- a/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
+++ b/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
@@ -115,8 +115,7 @@ async def post_activity(
             data = (await resp.read()).decode()
             content = json.loads(data) if data else None
 
-            if content:
-                return InvokeResponse(status=resp.status, body=content)
+            return InvokeResponse(status=resp.status, body=content)
 
         finally:
             # Restore activity properties.


Test patch:
Repository: microsoft/botbuilder-python

Issue:
[PORT] [Certificate Authentication] Expose sendX5c parameter
> Port this change from botbuilder-dotnet/master branch:
https://github.com/microsoft/botbuilder-dotnet/pull/3741

This parameter enables application developers to achieve easy certificates roll-over in Azure AD: setting this parameter to true will send the public certificate to Azure AD along with the token request, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. This saves the application admin from the need to explicitly manage the certificate rollover (either via portal or powershell/CLI operation)


# Changed projects
* Microsoft.Bot.Connector

[R9,authentication]





Discussion:

Resolving patch:
diff --git a/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py b/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py
--- a/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py
+++ b/libraries/botframework-connector/botframework/connector/auth/certificate_app_credentials.py
@@ -23,7 +23,20 @@ def __init__(
         certificate_private_key: str,
         channel_auth_tenant: str = None,
         oauth_scope: str = None,
+        certificate_public: str = None,
     ):
+        """
+        AppCredentials implementation using a certificate.
+
+        :param app_id:
+        :param certificate_thumbprint:
+        :param certificate_private_key:
+        :param channel_auth_tenant:
+        :param oauth_scope:
+        :param certificate_public: public_certificate (optional) is public key certificate which will be sent
+        through ‘x5c’ JWT header only for subject name and issuer authentication to support cert auto rolls.
+        """
+
         # super will set proper scope and endpoint.
         super().__init__(
             app_id=app_id,
@@ -35,6 +48,7 @@ def __init__(
         self.app = None
         self.certificate_thumbprint = certificate_thumbprint
         self.certificate_private_key = certificate_private_key
+        self.certificate_public = certificate_public
 
     def get_access_token(self, force_refresh: bool = False) -> str:
         """
@@ -63,6 +77,9 @@ def __get_msal_app(self):
                 client_credential={
                     "thumbprint": self.certificate_thumbprint,
                     "private_key": self.certificate_private_key,
+                    "public_certificate": self.certificate_public
+                    if self.certificate_public
+                    else None,
                 },
             )
 
diff --git a/libraries/botframework-connector/setup.py b/libraries/botframework-connector/setup.py
--- a/libraries/botframework-connector/setup.py
+++ b/libraries/botframework-connector/setup.py
@@ -12,7 +12,7 @@
     "PyJWT==1.5.3",
     "botbuilder-schema>=4.7.1",
     "adal==1.2.1",
-    "msal==1.1.0",
+    "msal==1.2.0",
 ]
 
 root = os.path.abspath(os.path.dirname(__file__))


Test patch:
Repository: microsoft/botbuilder-python

Issue:
[PORT] Add state to AppBasedLinkQuery for OAuth flow
> Port this change from botbuilder-dotnet/master branch:
https://github.com/microsoft/botbuilder-dotnet/pull/3732

Fixes: #3429


# Changed projects
* Microsoft.Bot.Schema






Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-schema/botbuilder/schema/teams/_models_py3.py b/libraries/botbuilder-schema/botbuilder/schema/teams/_models_py3.py
--- a/libraries/botbuilder-schema/botbuilder/schema/teams/_models_py3.py
+++ b/libraries/botbuilder-schema/botbuilder/schema/teams/_models_py3.py
@@ -39,15 +39,19 @@ class AppBasedLinkQuery(Model):
 
     :param url: Url queried by user
     :type url: str
+    :param state: The magic code for OAuth Flow
+    :type state: str
     """
 
     _attribute_map = {
         "url": {"key": "url", "type": "str"},
+        "state": {"key": "state", "type": "str"},
     }
 
-    def __init__(self, *, url: str = None, **kwargs) -> None:
+    def __init__(self, *, url: str = None, state: str = None, **kwargs) -> None:
         super(AppBasedLinkQuery, self).__init__(**kwargs)
         self.url = url
+        self.state = state
 
 
 class ChannelInfo(Model):


Test patch:
Repository: microsoft/botbuilder-python

Issue:
[PORT] Fix the interface name in the error message.
> Port this change from botbuilder-dotnet/master branch:
https://github.com/microsoft/botbuilder-dotnet/pull/3633

Interface looks like it changed name but the name in the error message didn't.


# Changed projects
* Microsoft.Bot.Builder.Dialogs






Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/oauth_prompt.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/oauth_prompt.py
--- a/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/oauth_prompt.py
+++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/oauth_prompt.py
@@ -124,7 +124,7 @@ async def begin_dialog(
         """
         if dialog_context is None:
             raise TypeError(
-                f"OAuthPrompt.begin_dialog: Expected DialogContext but got NoneType instead"
+                f"OAuthPrompt.begin_dialog(): Expected DialogContext but got NoneType instead"
             )
 
         options = options or PromptOptions()
@@ -149,7 +149,7 @@ async def begin_dialog(
 
         if not isinstance(dialog_context.context.adapter, UserTokenProvider):
             raise TypeError(
-                "OAuthPrompt.get_user_token(): not supported by the current adapter"
+                "OAuthPrompt.begin_dialog(): not supported by the current adapter"
             )
 
         output = await dialog_context.context.adapter.get_user_token(
@@ -357,7 +357,7 @@ async def _send_oauth_card(
             ):
                 if not hasattr(context.adapter, "get_oauth_sign_in_link"):
                     raise Exception(
-                        "OAuthPrompt.send_oauth_card(): get_oauth_sign_in_link() not supported by the current adapter"
+                        "OAuthPrompt._send_oauth_card(): get_oauth_sign_in_link() not supported by the current adapter"
                     )
 
                 link = await context.adapter.get_oauth_sign_in_link(
@@ -450,12 +450,12 @@ async def _recognize_token(self, context: TurnContext) -> PromptRecognizerResult
                     self._get_token_exchange_invoke_response(
                         int(HTTPStatus.BAD_GATEWAY),
                         "The bot's BotAdapter does not support token exchange operations."
-                        " Ensure the bot's Adapter supports the ITokenExchangeProvider interface.",
+                        " Ensure the bot's Adapter supports the ExtendedUserTokenProvider interface.",
                     )
                 )
 
                 raise AttributeError(
-                    "OAuthPrompt.recognize(): not supported by the current adapter."
+                    "OAuthPrompt._recognize_token(): not supported by the current adapter."
                 )
             else:
                 # No errors. Proceed with token exchange.


Test patch:
Repository: microsoft/botbuilder-python

Issue:
onTeamsMembersAddedEvent handler doesn't run when bot is the member
When a bot receives an onTeamsMemberAdded event where the member added was the bot, a 502 error is thrown, which results in this event never being fired.

Cause:
The event calls the getMember API, which is the source of the 502. This API cannot be passed a bot ID.

Fix:
Check to see if the member added is the bot, and if it is return a truncated TeamsChannelAccount.



Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-core/botbuilder/core/teams/teams_activity_handler.py b/libraries/botbuilder-core/botbuilder/core/teams/teams_activity_handler.py
--- a/libraries/botbuilder-core/botbuilder/core/teams/teams_activity_handler.py
+++ b/libraries/botbuilder-core/botbuilder/core/teams/teams_activity_handler.py
@@ -350,7 +350,11 @@ async def on_teams_members_added_dispatch(  # pylint: disable=unused-argument
 
         team_members_added = []
         for member in members_added:
-            if member.additional_properties != {}:
+            is_bot = (
+                turn_context.activity.recipient is not None
+                and member.id == turn_context.activity.recipient.id
+            )
+            if member.additional_properties != {} or is_bot:
                 team_members_added.append(
                     deserializer_helper(TeamsChannelAccount, member)
                 )


Test patch:
diff --git a/libraries/botbuilder-core/tests/teams/test_teams_activity_handler.py b/libraries/botbuilder-core/tests/teams/test_teams_activity_handler.py
--- a/libraries/botbuilder-core/tests/teams/test_teams_activity_handler.py
+++ b/libraries/botbuilder-core/tests/teams/test_teams_activity_handler.py
@@ -385,6 +385,38 @@ async def test_on_teams_members_added_activity(self):
         assert bot.record[0] == "on_conversation_update_activity"
         assert bot.record[1] == "on_teams_members_added"
 
+    async def test_bot_on_teams_members_added_activity(self):
+        # arrange
+        activity = Activity(
+            recipient=ChannelAccount(id="botid"),
+            type=ActivityTypes.conversation_update,
+            channel_data={
+                "eventType": "teamMemberAdded",
+                "team": {"id": "team_id_1", "name": "new_team_name"},
+            },
+            members_added=[
+                ChannelAccount(
+                    id="botid",
+                    name="test_user",
+                    aad_object_id="asdfqwerty",
+                    role="tester",
+                )
+            ],
+            channel_id=Channels.ms_teams,
+            conversation=ConversationAccount(id="456"),
+        )
+
+        turn_context = TurnContext(SimpleAdapter(), activity)
+
+        # Act
+        bot = TestingTeamsActivityHandler()
+        await bot.on_turn(turn_context)
+
+        # Assert
+        assert len(bot.record) == 2
+        assert bot.record[0] == "on_conversation_update_activity"
+        assert bot.record[1] == "on_teams_members_added"
+
     async def test_on_teams_members_removed_activity(self):
         # arrange
         activity = Activity(
Repository: microsoft/botbuilder-python

Issue:
No module named 'botbuilder.ai.qna.dialogs' - Python QnA Sample 49
## Version
botbuilder-ai - 4.9.1

## Describe the bug
I was trying out the QnA Maker Sample - 49.qnamaker-all-features . I've configured my QnA KB and also the config.py with the necessary info. However the module botbuilder.ai.qna.dialogs does not seem to exist. I've manually verified for the class QnAMakermDialog and it does not exist

> from botbuilder.ai.qna.dialogs import QnAMakermDialog

## To Reproduce
Steps to reproduce the behavior:
1. Download the sample 49.qnamaker-all-features
2. Install the necessary requirements and configure QnAMaker.
3. Run python app.py in the folder

## Expected behavior
The sample should've run successfully.


[bug]



Discussion:
@vijaysaimutyala Where are you seeing that import line?  The actual class name should be QnAMakerDialog (not QnAMakermDialog).
@tracyboehrer Sorry that might be a typo. You can look the import [here](https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/python/49.qnamaker-all-features/app.py) I rectified the typo and still couldn't see the module. Below is the screenshot from my local env. I'm somehow missing the dialogs part I see on the Botbuilder-python [repo](https://github.com/microsoft/botbuilder-python/tree/c15c61523c4b69f81bddbfd49e1be910beca0cdd/libraries/botbuilder-ai/botbuilder/ai/qna/dialogs)

![image](https://user-images.githubusercontent.com/7084628/86011594-7f031780-ba3a-11ea-86d5-5b205d75a869.png)

I tried updating botbuilder-ai, but its already at 4.9.1
A quick update. I created a fresh conda environment and installed the requirements of the [sample 49](https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/49.qnamaker-all-features) but I faced the same issue again. Also I noticed on the Samples homepage that the Python sample link is not updated yet. 

![image](https://user-images.githubusercontent.com/7084628/86012756-fd13ee00-ba3b-11ea-9caa-c46415d7d652.png)

@vijaysaimutyala This is a bug on our side.  We didn't provide an export for the dialogs package.
Thanks for checking @tracyboehrer Let me know if I can help in any way.

Resolving patch:
diff --git a/libraries/botbuilder-ai/setup.py b/libraries/botbuilder-ai/setup.py
--- a/libraries/botbuilder-ai/setup.py
+++ b/libraries/botbuilder-ai/setup.py
@@ -39,6 +39,7 @@
         "botbuilder.ai.luis",
         "botbuilder.ai.qna.models",
         "botbuilder.ai.qna.utils",
+        "botbuilder.ai.qna.dialogs",
     ],
     install_requires=REQUIRES + TESTS_REQUIRES,
     tests_require=TESTS_REQUIRES,


Test patch:
Repository: microsoft/botbuilder-python

Issue:
Update CardAction to support alt text for images on buttons
See [parent](https://github.com/microsoft/botframework-sdk/issues/5874)


Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-schema/botbuilder/schema/_models_py3.py b/libraries/botbuilder-schema/botbuilder/schema/_models_py3.py
--- a/libraries/botbuilder-schema/botbuilder/schema/_models_py3.py
+++ b/libraries/botbuilder-schema/botbuilder/schema/_models_py3.py
@@ -1196,6 +1196,8 @@ class CardAction(Model):
     :type value: object
     :param channel_data: Channel-specific data associated with this action
     :type channel_data: object
+    :param image_alt_text: Alternate image text to be used in place of the `image` field
+    :type image_alt_text: str
     """
 
     _attribute_map = {
@@ -1206,6 +1208,7 @@ class CardAction(Model):
         "display_text": {"key": "displayText", "type": "str"},
         "value": {"key": "value", "type": "object"},
         "channel_data": {"key": "channelData", "type": "object"},
+        "image_alt_text": {"key": "imageAltText", "type": "str"},
     }
 
     def __init__(
@@ -1218,6 +1221,7 @@ def __init__(
         display_text: str = None,
         value=None,
         channel_data=None,
+        image_alt_text: str = None,
         **kwargs
     ) -> None:
         super(CardAction, self).__init__(**kwargs)
@@ -1228,6 +1232,7 @@ def __init__(
         self.display_text = display_text
         self.value = value
         self.channel_data = channel_data
+        self.image_alt_text = image_alt_text
 
 
 class CardImage(Model):


Test patch: