Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use v5 API host in QnAMakerDialog or construct v4 API host #2004

Merged
merged 10 commits into from
Apr 18, 2020

Conversation

stevengum
Copy link
Member

@stevengum stevengum commented Apr 9, 2020

Do not merge without review from @vipeketi


Fixes breaking change in #1999 while still addressing #1885

Description

This PR changes the logic in QnAMakerDialog.getQnAClient() to use the dialog instance's hostName if it contains 'qnamaker/v5' otherwise use the pre-#1999 behavior of constructing a v4 API endpoint with a template literal.

This PR also adds missing validation to the QnAMakerDialog constructor (C#) and fixes the doc string on the QnAMakerEndpoint interface.

Specific Changes

  • Use hostName if it is a v5 API host, otherwise construct v4 API host value
  • Added unit tests for QnAMakerDialog.getQnAClient()
  • Add missing validation checks for QnAMakerDialog constructor
  • Add tests for new valdiation in QnAMakerDialog
  • Fix QnAMakerEndpoint doc string on host
  • Remove unused imports in QnAMaker

@stevengum stevengum added P0 Must Fix. Release-blocker R9 Release 9 - May 15th, 2020 labels Apr 9, 2020
@coveralls
Copy link

coveralls commented Apr 9, 2020

Pull Request Test Coverage Report for Build 121114

  • 20 of 22 (90.91%) changed or added relevant lines in 2 files are covered.
  • 9 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 67.259%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder-ai/src/qnaMakerDialog.ts 19 21 90.48%
Files with Coverage Reduction New Missed Lines %
libraries/botframework-streaming/src/webSocket/webSocketTransport.ts 2 80.65%
libraries/botframework-streaming/src/webSocket/webSocketServer.ts 7 66.67%
Totals Coverage Status
Change from base Build 119935: -0.04%
Covered Lines: 10332
Relevant Lines: 14534

💛 - Coveralls

Copy link
Contributor

@vipeketi vipeketi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline lets us hold this PR, as we have PR lined up which has conflict.

@@ -352,8 +363,22 @@ export class QnAMakerDialog extends WaterfallDialog {
const endpoint = {
knowledgeBaseId: this.knowledgeBaseId,
endpointKey: this.endpointKey,
host: this.hostName
host: this.constructHttpsHostName(this.hostName)
};
return new QnAMaker(endpoint);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hostname format for QnAMaker V5 also need to be accommodated. Sample hostname for QnAMaker V5 is https://qnamaker-acom.azure.com/qnamaker/v5.0-preview.1.

Copy link
Member Author

@stevengum stevengum Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vipeketi, per our offline discussions and the internal doc, what if we look for "qnamaker/v5.0" in this.hostName?

private getQnAClient(): QnAMaker {
    const host = this.hostName.includes('qnamaker/v5.0')
                 ? this.hostName
                 : this.constructHttpsHostName(this.hostName);

    const endpoint = {
        knowledgeBaseId: this.knowledgeBaseId,
        endpointKey: this.endpointKey,
        host
    };
    return new QnAMaker(endpoint);
}

I'll iterate a couple of times to make the code clearer (e.g. change constructHttpsHostName() to constructV4ApiHost())

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vipeketi, here is the latest commit that supports the old behavior around constructing a v4 API endpoint while first inspecting to see if the endpoint is for the v5 API ("qnamaker/v5")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v5 handling looks good to me. When source code is downloaded from portal , the appsettings pre-populate complete url like https://xxx.azurewebsites.com/qnamaker. Can we skip just the hostname as value for this.hostName.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't skip the template literal because that's a breaking change, but we can add logic to examine the provided value:

If the hostname looks like this: xxx.azurewebsites.net, then it's probably in the appsettings of a downloaded or deployed bot through Azure. We can apply the logic from your recent PR to the samples: microsoft/BotBuilder-Samples@b834e98.

If it looks like https://xxx.azurewebsites.net/qnamaker, then it's probably gathered from the QnAMaker portal, and it doesn't need to be touched up in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can accomodate support for https://xxx.azurewebsites.net/qnamaker and qnamaker/v5.0, I am good with the changes.

@stevengum stevengum changed the title Construct endpoint if QnAMakerDialog.hostName is not "complete" Use v5 API host in QnAMakerDialog or construct v4 API host Apr 13, 2020
@stevengum stevengum requested a review from vipeketi April 17, 2020 16:28
Copy link
Contributor

@vipeketi vipeketi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@stevengum stevengum merged commit a21e186 into master Apr 18, 2020
@stevengum stevengum deleted the stgum/qnaMaker branch April 21, 2020 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Must Fix. Release-blocker R9 Release 9 - May 15th, 2020
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants