Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultExceptionSerializationStrategy throws System.NullReferenceException #252

Open
kvattikuti opened this issue Jun 17, 2022 · 3 comments

Comments

@kvattikuti
Copy link

kvattikuti commented Jun 17, 2022

AWSSDK.XRay Version="3.7.0.29"
AWSXRayRecorder.Handlers.AwsSdk Version="2.8.3"

NullReferenceException: Exception: Object reference not set to an instance of an object.
at Amazon.XRay.Recorder.Core.Strategies.DefaultExceptionSerializationStrategy.<>c__DisplayClass14_0.<DescribeException>b__3(ExceptionDescriptor d)
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Amazon.XRay.Recorder.Core.Strategies.DefaultExceptionSerializationStrategy.DescribeException(Exception e, IEnumerable`1 subsegments)
at Amazon.XRay.Recorder.Core.Internal.Entities.Entity.AddException(Exception e)
at Amazon.XRay.Recorder.Core.AWSXRayRecorderImpl.AddException(Exception ex)
at Ecova.DaaS.Aws.LambdaEntryPoints.HttpApi.HttpRestApiLogger.AddXrayAnnotations(IAWSXRayRecorder xrayRecorder, ApiGatewayProxyRequestWrapper requestWrapper, RequestAnnotations requestAnnotations, String partyMemberIdentifier, String awsRequestId, String correlationId, Exception exception, String errorString) in /src/Aws/Ecova.DaaS.Aws.LambdaEntryPoints/HttpApi/HttpRestApiLogger.cs:line 103
at Ecova.DaaS.Aws.LambdaEntryPoints.HttpApi.HttpRestApiLogger.LogResponse(ILogger logger, IAWSXRayRecorder xrayRecorder, ApiGatewayProxyRequestWrapper requestWrapper, String partyMemberIdentifier, RequestAnnotations requestAnnotations, Int32 httpStatusCode, Int64 timeTakenToCompleteRequest, String awsRequestId, String correlationId, Exception exception, String responseBody) in /src/Aws/Ecova.DaaS.Aws.LambdaEntryPoints/HttpApi/HttpRestApiLogger.cs:line 52
at Ecova.DaaS.Aws.LambdaEntryPoints.HttpApi.HttpRestApi.FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) in /src/Aws/Ecova.DaaS.Aws.LambdaEntryPoints/HttpApi/HttpRestApi.cs:line 145

This happens when we IAWSXRayRecorder.AddException() to X-ray recorder. It happens intermittently.

Not sure how much of help this is but here is the stacktrace of the exception we are trying to add:


Exception: 1 validation error detected: Value at 'records.1.member.data' failed to satisfy constraint: Member must have length less than or equal to 1048576
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionStream(IRequestContext requestContext, IWebResponseData httpErrorResponse, HttpErrorResponseException exception, Stream responseStream)
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionAsync(IExecutionContext executionContext, HttpErrorResponseException exception)
at Amazon.Runtime.Internal.ExceptionHandler`1.HandleAsync(IExecutionContext executionContext, Exception exception)
at Amazon.Runtime.Internal.ErrorHandler.ProcessExceptionAsync(IExecutionContext executionContext, Exception exception)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
at Ecova.DaaS.DependencyInjection.Aws.Implementations.KinesisBatchSender`1.SendBatchHelperInner(List`1 requests) in /src/Aws/Ecova.DaaS.DependencyInjection.Aws/Implementations/KinesisBatchSender.cs:line 202
at Ecova.DaaS.DependencyInjection.Aws.Implementations.KinesisBatchSender`1.<>c__DisplayClass22_0.<<SendBatchHelper>b__0>d.MoveNext() in /src/Aws/Ecova.DaaS.DependencyInjection.Aws/Implementations/KinesisBatchSender.cs:line 174
--- End of stack trace from previous location where exception was thrown ---
at Polly.AsyncPolicy.<>c__DisplayClass40_0.<<ImplementationAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
Inner-Exception: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)

See related issue #96 which was closed without fixing it because of inactivity.

@srprash
Copy link
Collaborator

srprash commented Jul 5, 2022

Hi @kvattikuti
Apologies that the previously related issue was closed pre-maturely.
I am trying to reproduce this issue but since it seems intermittent, I haven't been successful yet.

From the stack trace of your exception, I am not able to determine if this is happening only for a specific type of exception from the AWS SDK client (for kinesis?).
Can you provide a snippet of code showing how you're calling the AWS service via the client, and what is the exception you are getting which in turn is leading to the NullReferenceException in the X-Ray SDK? Thanks!

@jon-armen
Copy link
Contributor

@srprash , @kvattikuti - This looks like the exact same exception I was getting in #209 which was fixed by #210. That is now released in AWSXRayRecorder.Handlers.AwsSdk v2.9.0

@NathanielRN
Copy link
Contributor

@kvattikuti could you please try importing the latest release and verify if that fix worked for you? If it does, can you close the issue? Thanks! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants