From ef425c4c6e9a8f4f66fb0936b5c2ddf91e82167f Mon Sep 17 00:00:00 2001 From: Gabo Gilabert Date: Fri, 4 Sep 2020 14:39:23 -0400 Subject: [PATCH] Add catch for JsonException in GetBodyContent. (#4596) --- .../BotFrameworkHttpClient.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/BotFrameworkHttpClient.cs b/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/BotFrameworkHttpClient.cs index d513b52475..e681749110 100644 --- a/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/BotFrameworkHttpClient.cs +++ b/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/BotFrameworkHttpClient.cs @@ -211,7 +211,15 @@ protected virtual async Task BuildCredentialsAsync(string appId, private static T GetBodyContent(string content) { - return JsonConvert.DeserializeObject(content); + try + { + return JsonConvert.DeserializeObject(content); + } + catch (JsonException) + { + // This will only happen when the skill didn't return valid json in the content (e.g. when the status code is 500 or there's a bug in the skill) + return default; + } } private async Task> SecurePostActivityAsync(Uri toUrl, Activity activity, string token, CancellationToken cancellationToken)