question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QnA Bot - The bot encountered an error or bug.

See original GitHub issue

Hi, I’m using this sample project for my customer. After some question, the bot encountered an error or bug.

Version

Microsoft.Bot.Builder.ApplicationInsights Version=“4.9.3” Microsoft.Bot.Builder.AI.QnA Version=“4.9.3” Microsoft.Bot.Builder.Azure Version=“4.9.3” Microsoft.Bot.Builder.Dialogs Version=“4.9.3” Microsoft.Bot.Builder.Dialogs.Adaptive Version=“4.9.3” Microsoft.Bot.Builder.Dialogs.Debugging Version=“4.9.3-preview” Microsoft.Bot.Builder.Integration.ApplicationInsights.Core Version=“4.9.3” Microsoft.Bot.Builder.Integration.AspNet.Core Version=“4.9.3”

Describe the bug

After some question, the bot encountered an error or bug. Application Insight error: Message: {“Errors”:[“The request payload is invalid. Ensure to provide a valid request payload.”]} ActivityId: d028a73a-d5c9-46ae-88dd-432310eb2593, Request URI: /apps/8831225b-cd4a-48ff-b6eb-ba1e2c4b8d40/services/b90f0b60-58ed-4f78-8a78-288cd79f4888/partitions/600ed71a-75e4-4072-bf4c-b60c8d08de10/replicas/132322046690328222p/, RequestStats: RequestStartTime: 2020-06-12T07:36:11.0372961Z, RequestEndTime: 2020-06-12T07:36:11.0473189Z, Number of regions attempted:1 ResponseTime: 2020-06-12T07:36:11.0473189Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-westeurope1-fd8.documents.azure.com:14144/apps/8831225b-cd4a-48ff-b6eb-ba1e2c4b8d40/services/b90f0b60-58ed-4f78-8a78-288cd79f4888/partitions/600ed71a-75e4-4072-bf4c-b60c8d08de10/replicas/132322046690328222p/, LSN: 1730, GlobalCommittedLsn: 1730, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 0, RequestCharge: 12.05, ItemLSN: -1, SessionToken: 0#1730#12=-1, UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Upsert , SDK: Microsoft.Azure.Documents.Common/2.11.0, Windows/10.0.14393 documentdb-netcore-sdk/2.1.2

Cosmos question detail

Remote dependency name: Create/query document command: https://botfouredu-westeurope.documents.azure.com/dbs/MHFSAA==/colls/MHFSAMVv1dc=/docs Operation Id: 1d8fbef23a6e5d4090ca59bf9969f9ea Parent Id: ba2698a154bd4048

Call Stack: Microsoft.Azure.Documents.DocumentClientException: at Microsoft.Azure.Documents.Client.ClientExtensions+<ParseResponseAsync>d__1.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.GatewayStoreModel+<>c__DisplayClass20_0+<<InvokeAsync>b__0>d.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.BackoffRetryUtility1+<>c__DisplayClass1_0+<<ExecuteAsync>b__0>d.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.BackoffRetryUtility1+<ExecuteRetryAsync>d__5.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at Microsoft.Azure.Documents.BackoffRetryUtility1+<ExecuteRetryAsync>d__5.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.BackoffRetryUtility1+<ExecuteAsync>d__1.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.GatewayStoreModel+<InvokeAsync>d__20.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.GatewayStoreModel+<ProcessMessageAsync>d__12.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.Client.DocumentClient+<UpsertAsync>d__308.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.Client.DocumentClient+<UpsertDocumentPrivateAsync>d__274.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.BackoffRetryUtility1+<>c__DisplayClass1_0+<<ExecuteAsync>b__0>d.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.BackoffRetryUtility1+<ExecuteRetryAsync>d__5.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at Microsoft.Azure.Documents.BackoffRetryUtility1+<ExecuteRetryAsync>d__5.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.BackoffRetryUtility1+<ExecuteAsync>d__1.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.Documents.Client.DocumentClient+<UpsertDocumentInlineAsync>d__273.MoveNext (Microsoft.Azure.DocumentDB.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Bot.Builder.Azure.CosmosDbStorage+<WriteAsync>d__15.MoveNext (Microsoft.Bot.Builder.Azure, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Bot.Builder.BotState+<SaveChangesAsync>d__5.MoveNext (Microsoft.Bot.Builder, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at BotFourEdu.Bots.DialogBot`1+<OnTurnAsync>d__5.MoveNext (BotFourEdu, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullBotFourEdu, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: D:\VSTS\MicrosoftEdu\BotFourEdu\BotFourEdu\BotFourEdu\Bots\DialogBot.csBotFourEdu, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 33) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Bot.Builder.BotFrameworkAdapter+TenantIdWorkaroundForTeamsMiddleware+<OnTurnAsync>d__0.MoveNext (Microsoft.Bot.Builder, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Bot.Builder.MiddlewareSet+<ReceiveActivityWithStatusAsync>d__3.MoveNext (Microsoft.Bot.Builder, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Bot.Builder.BotAdapter+<RunPipelineAsync>d__18.MoveNext (Microsoft.Bot.Builder, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)

To Reproduce

Open QnA bot, make some questions and then encounter error.

Expected behavior

No Cosmos error

image

Application Insight details query_data.xlsx

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
praveenck06commented, Jul 8, 2020

we are also facing this issue. it happens when await stepContext.BeginDialogAsync(); is called multiple times. the error is originated from the await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); inside the DialogBot.cs

We are using bot.builder 4.5.1

Code to save conversationState:

      ` public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = 
      default(CancellationToken))
    {
        var activity = turnContext.Activity;

        if (string.IsNullOrWhiteSpace(activity.Text) && activity.Value != null)
        {
            activity.Text = JsonConvert.SerializeObject(activity.Value);
        }

        await base.OnTurnAsync(turnContext, cancellationToken);

        // Save any state changes that might have occured during the turn.
        await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
        await UserState.SaveChangesAsync(turnContext, false, cancellationToken);
    }`

Exception: Message: {“Errors”:[“The request payload is invalid. Ensure to provide a valid request payload.”]} ActivityId: c91ba9c8-b927-408d-96d4-8bc4a2dfd106, Request URI: /6657d7ac-94f1-4464-8bdd-5c881515c4a2/services/8adb343c-14f0-4ffa-9257-471c969e4bb4/partitions/99ba15bc-95d7-4da9-ad7a-bcb50a686095/replicas/132356544187921215p/, RequestStats: RequestStartTime: 2020-07-08T04:47:35.9657876Z, RequestEndTime: 2020-07-08T04:47:35.9657876Z, Number of regions attempted:1 ResponseTime: 2020-07-08T04:47:35.9657876Z, StoreResult: StorePhysicalAddress: rntbd://-ms-westeurope1-fd21.documents.azure.com:14351/apps/6657d7ac-94f1-4464-8bdd-5c881515c4a2/services/8adb343c-14f0-4ffa-9257-471c969e4bb4/partitions/99ba15bc-95d7-4da9-ad7a-bcb50a686095/replicas/, LSN: 37799, GlobalCommittedLsn: 37799, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 0, RequestCharge: 2.81, ItemLSN: -1, SessionToken: -1#37799, UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Upsert , SDK: Microsoft.Azure.Documents.Common/2.11.0, Windows/10.0.14393 documentdb-netcore-sdk/2.6.0

Exception.StackTrace: at Microsoft.Azure.Documents.GatewayStoreClient.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings, DocumentServiceRequest request) at Microsoft.Azure.Documents.GatewayStoreClient.InvokeAsync(DocumentServiceRequest request, ResourceType resourceType, Uri physicalAddress, CancellationToken cancellationToken) at Microsoft.Azure.Documents.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken) at Microsoft.Azure.Documents.Client.DocumentClient.ProcessRequestAsync(DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicyInstance, CancellationToken cancellationToken) at Microsoft.Azure.Documents.Client.DocumentClient.UpsertDocumentPrivateAsync(String documentCollectionLink, Object document, RequestOptions options, Boolean disableAutomaticIdGeneration, IDocumentClientRetryPolicy retryPolicyInstance, CancellationToken cancellationToken) at Microsoft.Azure.Documents.BackoffRetryUtility1.ExecuteRetryAsync(Func1 callbackMethod, Func3 callShouldRetry, Func1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action1 preRetryCallback) at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException) at Microsoft.Azure.Documents.BackoffRetryUtility1.ExecuteRetryAsync(Func1 callbackMethod, Func3 callShouldRetry, Func1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action1 preRetryCallback) at Microsoft.Azure.Documents.Client.DocumentClient.UpsertDocumentInlineAsync(String documentsFeedOrDatabaseLink, Object document, RequestOptions options, Boolean disableAutomaticIdGeneration, CancellationToken cancellationToken) at Microsoft.Bot.Builder.Azure.CosmosDbStorage.WriteAsync(IDictionary2 changes, CancellationToken cancellationToken) at Microsoft.Bot.Builder.BotState.SaveChangesAsync(ITurnContext turnContext, Boolean force, CancellationToken cancellationToken) at Bots.DialogBot1.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in C:\Bots\DialogBot.cs:line 52 at Microsoft.Bot.Builder.TelemetryLoggerMiddleware.OnTurnAsync(ITurnContext context, NextDelegate nextTurn, CancellationToken cancellationToken) at Microsoft.Bot.Builder.TranscriptLoggerMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, CancellationToken cancellationToken) at Microsoft.Bot.Builder.BotFrameworkAdapter.TenantIdWorkaroundForTeamsMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken)


We are using cosmos db as bot stroage

0reactions
praveenck06commented, Jul 13, 2020

No we are using core bot. Bot builder version is 4.5.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

The bot encountered an error or bug. To continue to run ...
In bot services click on "Channels" tab top of "Test in Web Chat" menu. · Same as point number 1 click on "Configuration"...
Read more >
The bot encountered an error or bug.To continue to run this ...
My bot has been working till yesterday and all of a sudden i get this error when i ask an question "The bot...
Read more >
"The bot encountered an error or bug. " Error Testing Bot ...
Firstly, I had to make some modifications to rename "EchoBot" to "MyBot" in order to get the code to run. However, upon testing,...
Read more >
The bot encountered an error or bug. To continue to run ...
This is custom Bot sample created for Teams, I don't think it will work on all the channels e.g., Emulator/WebChat etc.
Read more >
[OutSystems.AI Chatbot] Chatbot widget sending out empty ...
... that the component is sending empty string messages to the bot which makes the bot respond with "The bot encountered an error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found