QnA Bot - The bot encountered an error or bug.
See original GitHub issueHi, 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.BackoffRetryUtility
1+<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.BackoffRetryUtility
1+<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.BackoffRetryUtility
1+<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.BackoffRetryUtility
1+<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
Application Insight details query_data.xlsx
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top GitHub Comments
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:
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.BackoffRetryUtility
1.ExecuteRetryAsync(Func
1 callbackMethod, Func3 callShouldRetry, Func
1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action1 preRetryCallback) at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException) at Microsoft.Azure.Documents.BackoffRetryUtility
1.ExecuteRetryAsync(Func1 callbackMethod, Func
3 callShouldRetry, Func1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action
1 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.DialogBot
1.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
No we are using core bot. Bot builder version is 4.5.1