How to make XunitExceptions more meaningful? - c#

I have a bunch of instances and properties they I would like to validate using XUnit.
myInstance.SomeProperty1.Should().HaveCount(2);
myInstance.SomeProperty2.Should().HaveCount(2);
[...]
myInstance.SomePropertyN.Should().HaveCount(2);
When this asserts fail, they throw the following kind of exceptions
Xunit.Sdk.XunitException
Expected collection to contain 2 item(s), but found 0.
at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message)
at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args)
at FluentAssertions.Collections.SelfReferencingCollectionAssertions`2.HaveCount(Int32 expected, String because, Object[] becauseArgs)
at [...]
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xunit.Sdk.ExecutionTimer.<AggregateAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xunit.Sdk.ExceptionAggregator.<RunAsync>d__9.MoveNext()
So far so good. But how can I make the exception more meaningful? I would like to see the name of the property on which the assert failed.
The thing is, this are quite big objects and spinning up the test always takes quite some time. Knowing on which property the tests failed would speed up my testing process. Thanks in advance!

Related

Exception while invoking Graph API URL

We are receiving an error for a single user when using the Graph API. We are not receiving this error for other user accounts. The process is going through e-mail subjects looking for subjects that begin with certain phrases. If they begin with these phrases it marks their calendars as "On Leave" for those appointments.
Has anyone run into an error like this or have some tips for troubleshooting?
Thank you,
Brian Aldridge
LeaveExchangeSync Errored -- System.AggregateException: One or more errors occurred. ---> System.Exception: Exception while invoking Graph API URL https://graph.microsoft.com/beta/Users/aankrah#resdat.com/calendar/calendarView?startDateTime=2019-11-17T19:04:41&endDateTime=2021-11-17T19:04:41&top=100 ---> Microsoft.Graph.ServiceException: Code: UnknownError
Inner error
at Microsoft.Graph.HttpProvider.d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RDI.Core.Azure.GraphServiceClientExtensions.d__0.MoveNext() in C:\code\Intranet\RDI.Core\Azure\GraphServiceClientExtensions.cs:line 48
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RDI.Service.Plugins.LeaveExchangeSync.Office365Layer.d__3.MoveNext() in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\Office365Layer.cs:line 55
--- End of inner exception stack trace ---
at RDI.Service.Plugins.LeaveExchangeSync.Office365Layer.d__3.MoveNext() in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\Office365Layer.cs:line 87
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RDI.Service.Plugins.LeaveExchangeSync.CalendarService.<>c__DisplayClass21_0.<b__0>d.MoveNext() in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\CalendarService.cs:line 168
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
at RDI.Service.Plugins.LeaveExchangeSync.CalendarService.GetUserEvents(String user) in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\CalendarService.cs:line 168
at RDI.Service.Plugins.LeaveExchangeSync.CalendarService.GetVacationEvents(String user) in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\CalendarService.cs:line 152
at RDI.Service.Plugins.LeaveExchangeSync.CalendarService.SyncAutomatedAppointments(List1 users, List`1 appointments, String eventType) in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\CalendarService.cs:line 67
at RDI.Service.Plugins.LeaveExchangeSync.LeaveExchangeSync.OnTimer(Object sender, ElapsedEventArgs e) in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\LeaveExchangeSync.cs:line 109
---> (Inner Exception #0) System.Exception: Exception while invoking Graph API URL https://graph.microsoft.com/beta/Users/aankrah#resdat.com/calendar/calendarView?startDateTime=2019-11-17T19:04:41&endDateTime=2021-11-17T19:04:41&top=100 ---> Microsoft.Graph.ServiceException: Code: UnknownError
Inner error
at Microsoft.Graph.HttpProvider.d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RDI.Core.Azure.GraphServiceClientExtensions.d__0.MoveNext() in C:\code\Intranet\RDI.Core\Azure\GraphServiceClientExtensions.cs:line 48
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RDI.Service.Plugins.LeaveExchangeSync.Office365Layer.d__3.MoveNext() in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\Office365Layer.cs:line 55
--- End of inner exception stack trace ---
at RDI.Service.Plugins.LeaveExchangeSync.Office365Layer.d__3.MoveNext() in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\Office365Layer.cs:line 87
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RDI.Service.Plugins.LeaveExchangeSync.CalendarService.<>c__DisplayClass21_0.<b__0>d.MoveNext() in C:\code\Intranet\RDI.Service.Plugins.LeaveExchangeSync\CalendarService.cs:line 168<---
My best debugging tip would be to make that call with a tool such as postman. Inspect what's different about it from other users, or if the graph service is returning a valid HTTP code. It looks like the actual error is being buried beneath the libraries.

SQS can't send only qutations messages in .Net core

I have some scenarios where I need to send messages with body:
""
When I try to do that using the following code:
var sqsClient= new AmazonSQSClient(new BasicAWSCredentials("accessKeyId","SecretKey"), new AmazonSQSConfig()
{
ServiceURL ="https://sqs.eu-west-1.amazonaws.com/"
});
//obj value is "" and provided from user
var result = sqsClient.SendMessageAsync("queueURL", obj.ToString()).Result;
I get:
{Amazon.SQS.AmazonSQSException: The request must contain the parameter
MessageBody. ---> Amazon.Runtime.Internal.HttpErrorResponseException:
Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException'
was thrown. at
Amazon.Runtime.HttpWebRequestMessage.d__20.MoveNext()
in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler_mobile\HttpRequestMessageFactory.cs:line
539
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.HttpHandler1.<InvokeAsync>d__91.MoveNext()
in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\HttpHandler.cs:line
175
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.Unmarshaller.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.SQS.Internal.ValidationResponseHandler.<InvokeAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.ErrorHandler.d__51.MoveNext()
--- End of inner exception stack trace --- at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext
executionContext, HttpErrorResponseException exception) in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\HttpErrorResponseExceptionHandler.cs:line
60 at
Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext
executionContext, Exception exception) in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line
212 at
Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__51.MoveNext() in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\ErrorHandler.cs:line
104
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.CallbackHandler.d__91.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.EndpointDiscoveryHandler.<InvokeAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
Amazon.Runtime.Internal.EndpointDiscoveryHandler.d__21.MoveNext()
in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\EndpointDiscoveryHandler.cs:line
79
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__71.MoveNext()
in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\CredentialsRetriever.cs:line
98
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.RetryHandler.d__101.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__101.MoveNext()
in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\RetryHandler\RetryHandler.cs:line
153
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.CallbackHandler.d__91.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__91.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.ErrorCallbackHandler.d__51.MoveNext()
in
E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\ErrorCallbackHandler.cs:line
58
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__11.MoveNext()}
However sending:
" "
Works well!
Is there any workarrounds to send only
""
You say you are trying to set the body to "" but what you are actually doing is setting the body to the 0 byte empty string between the two ". A string literal does not actually contain the quotes that surround it. If empty string is what you actually want to send, that is not valid in SQS.
the message body must not be empty or null.
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html
However, if you're actually trying to send two bytes of ASCII 0x22 " quote characters, those would need to appear and be escaped inside your string literal.
var result = sqsClient.SendMessageAsync("queueURL", "\"\"").Result;
(Note that the citation from the SQS developer guide comes from a page concerned primarily with message atttibutes, but it does refer to the actual message body, not the message attributes, whose content is referred to as Value, not "body," and is mentioned separately as also not supporting empty or null.)

WEB API: The client disconnected [duplicate]

I'm getting the following error in logs for WebAPI
System.Web.HttpException (0x800703E3): The client disconnected. at
System.Web.Hosting.IIS7WorkerRequest.EndRead(IAsyncResult asyncResult)
at System.Web.HttpBufferlessInputStream.EndRead(IAsyncResult
asyncResult) at System.Threading.Tasks.TaskFactory
1.FromAsyncTrimPromise 1.Complete(TInstance thisRef, Func 3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.IO.StreamReader.d__97.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.IO.StreamReader.d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at Microsoft.Owin.OwinRequest.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware
1.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at Web.API.Middleware.OwinMiddleware.d__1.MoveNext()
in D:\UAT\Web.API\Middleware\OwinMiddleware.cs:line 49
How can I handle and ignore these exceptions by exception filter? Why this error occurs and how can I reproduce that? I wanna catch and ignore only The client disconnected but not all HttpException
I saw this similar question but how can I do that in exception filter?
You can ignore these exceptions.
The exception says what the problem is: "The client disconnected". It means that the client initiated a request but then disconnected before it bothered to read all of the response.
There are any numbers of reasons why that might be the case, but (unless you have a dodgy internet connection at your server end) it is almost certainly an issue at the client end. I regularly see these myself and mostly it seems to be related to a bot. So I filter them out and ignore them.
try
{
// Open Connection
// Do stuff
}
catch (HttpException ex)
{
// Log it?
// Ignore it?
// Do what you want with it?
}
finally
{
// Close connection
}

Server cannot append header after HTTP headers have been sent in Telerik Reporting

I have deployed a Telerik Report (v9.1.15.731) on a machine, and the report itself works great. But when I try to “Export” the report, or click the "Print" icon on it, after the “Save As” window appears and I save, the file doesn't get saved.
It eventually does get saved, but once in every 10-15 tries. But it is random. And this issue occurs only in Telerik's Reporting.
I have checked the EventViewer Log and found that the following exception appeared every time this issue was faced.
"Server cannot append header after HTTP headers have been sent."
Here is the full log:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 12-Dec-16 11:03:18 AM
Event time (UTC): 12-Dec-16 8:03:18 AM
Event ID: 3d4f8afcdaba4ed5bc5786c27a4311ee
Event sequence: 40
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/4/ROOT-7-131260033658791910
Trust level: Full
Application Virtual Path: /
Application Path: C:\Kit\CCB-GP-Reports\
Machine name: CCBSQL
Process information:
Process ID: 1384
Process name: w3wp.exe
Account name: CONSCRT\administrator
Exception information:
Exception type: HttpException
Exception message: Server cannot append header after HTTP headers have been sent.
at System.Web.HttpHeaderCollection.SetHeader(String name, String value, Boolean replace)
at Microsoft.Owin.Host.SystemWeb.CallHeaders.AspNetResponseHeaders.Set(String key, String[] values)
at Microsoft.Owin.Infrastructure.OwinHelpers.AppendHeaderUnmodified(IDictionary''2 headers, String key, String[] values)
at Microsoft.Owin.Infrastructure.ChunkingCookieManager.AppendResponseCookie(IOwinContext context, String key, String value, CookieOptions options)
at Microsoft.Owin.Security.Cookies.CookieAuthenticationHandler.d__f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware''1.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware''1.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Request information:
Request URL: http://ccbsql:1010/api/reports/clients/110315-5a11/instances/103714-54ba/documents/110316-df3e110316-3e23/resources/f6a8312b165f4639a029ba42c07f56bc/
Request path: /api/reports/clients/110315-5a11/instances/103714-54ba/documents/110316-df3e110316-3e23/resources/f6a8312b165f4639a029ba42c07f56bc/
User host address: 192.168.5.8
User: admin
Is authenticated: True
Authentication Type: ApplicationCookie
Thread account name: CONSCRT\administrator
Thread information:
Thread ID: 13
Thread account name: CONSCRT\administrator
Is impersonating: False
Stack trace: at System.Web.HttpHeaderCollection.SetHeader(String name, String value, Boolean replace)
at Microsoft.Owin.Host.SystemWeb.CallHeaders.AspNetResponseHeaders.Set(String key, String[] values)
at Microsoft.Owin.Infrastructure.OwinHelpers.AppendHeaderUnmodified(IDictionary''2 headers, String key, String[] values)
at Microsoft.Owin.Infrastructure.ChunkingCookieManager.AppendResponseCookie(IOwinContext context, String key, String value, CookieOptions options)
at Microsoft.Owin.Security.Cookies.CookieAuthenticationHandler.d__f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware''1.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware''1.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Custom event details:
I have been stuck on this issue for about a month now, and I would really appreciate any help, suggestions or ideas to find a fix for this.
Thank You!
Best Regards,
veggiedude

MongoDB C# drivers throws ArgumentNullException: Value cannot be null. Parameter name: serverVersion

MongoDB C# driver is throwing an ArgumentNullException for the parameter serverVersion on the code below. However, my code does not have any call to MongoDB that seems directly related to this parameter (or the SemanticVersion object in general). I have a code snippet below which exemplifies what I am doing.
This snippet runs in a microservice and actually works most of the time, however on the specific circumstance when this exception is thrown, my microservice is being moved across different instances, and the exception is thrown in my old instance. My expectation was that my code should handle the consistency in situations like that, so I was not expecting any specific error from MongoDB.
FilterDefinition<MyMongoObject> filter = Builders<MyMongoObject>.Filter.Eq(nameof(MyMongoObject.Id), id);
List<MyMongoObject> mongoResult = await this.mongoCollection.Find(filter).ToListAsync();
if (mongoResult.Count > 1) ...
Note that I am not sure if the exception is due to a consistency check, I only suspect since this code works fine during regular calls (i.e. when my main instance is not being decommissioned/moved).
Below is the stack trace in the exception, from the ToListAsync() call:
Error when syncing to Query StoreSystem.ArgumentNullException: Value cannot be null.
Parameter name: serverVersion
at MongoDB.Driver.ReadConcern.ThrowIfNotSupported(SemanticVersion serverVersion)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.CreateCommand(ServerDescription serverDescription)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.<ExecuteCommandAsync>d__110.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.<ExecuteAsync>d__107.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.Core.Operations.FindOperation`1.<ExecuteAsync>d__107.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.OperationExecutor.<ExecuteReadOperationAsync>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.MongoCollectionImpl`1.<ExecuteReadOperationAsync>d__59`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.IAsyncCursorSourceExtensions.<ToListAsync>d__16`1.MoveNext()

Categories