Botframework-webchat: Web Chat throwing 'adaptiveCard.validate is not a function' error

Created on 11 Jun 2019  路  2Comments  路  Source: microsoft/BotFramework-WebChat

Screenshots

image

Version

Version: 0.0.0-0
Local build from master branch

Describe the bug

In the most resent release of AdaptiveCards - v1.2 - the developers removed the validate function from the renderer. Web Chat updated the AdaptiveCards dependency in PR https://github.com/microsoft/BotFramework-WebChat/pull/2064 to v1.2; however, the AdaptiveCardRenderer component still uses the validate function. As a result, Web Chat is throwing an 'adaptiveCard.validate is not a function' error.

The CardElement.validate() and Action.validate() methods have been REMOVED, replaced with CardObject.validateProperties() and CardObject.internalValidateProperties(context: ValidationContext). Custom elements and actions now must override internalValidateProperties and add validation failures as appropriate to the context object passed as a parameter using its addFailure method. Be sure to always call super.internalValidateProperties(context) in your override.

https://www.npmjs.com/package/adaptivecards#breaking-changes

In addition to reconfiguring the AdaptiveCardRenderer component, AdaptiveCard tests should be added to prevent errors like this in the future.

To Reproduce

Send an AdaptiveCard to Web Chat

const card = CardFactory.adaptiveCard({
  "type": "AdaptiveCard",
  "body": [
      {
          "type": "TextBlock",
          "text": "AdaptiveCard"
      }
  ],
  "actions": [
      {
          "type": "Action.OpenUrl",
          "title": "Action.OpenUrl",
          "url": "https://microsoft.com"
      }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.1"
});

await context.sendActivity({ attachments: [card]});

[Bug]

Bug

All 2 comments

It looks like AdaptiveCards also removed the speak property from the TextBlock class in v1.2, and it is still being used in the AdaptiveCardBuilder component. Web Chat throws a "Property 'speak' does not exist on type 'TextBlock'" error during build.

image

THANK YOU for all the research @tdurnford!!!

Was this page helpful?
0 / 5 - 0 ratings