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

Adding the same exception to the xray trace handler in different subsegments throws a null reference exception #209

Closed
jon-armen opened this issue Jul 29, 2021 · 4 comments
Assignees

Comments

@jon-armen
Copy link
Contributor

This code should work, however currently throws a null reference exception because the existing cause does not have an exception associated.

            try
            {
                recorder.BeginSubsegment("child1");
                try
                {
                    try
                    {
                        recorder.BeginSubsegment("child2");
                        throw new AmazonServiceException();
                    }
                    catch (AmazonServiceException e)
                    {
                        recorder.AddException(e);
                        recorder.EndSubsegment();
                        throw;
                    }
                }
                catch (AmazonServiceException e)
                {
                    recorder.AddException(e);
                    recorder.EndSubsegment();
                    throw new EntityNotAvailableException("Dummy message", e);
                }
            }
            catch (EntityNotAvailableException e)
            {
                recorder.AddException(e);
                recorder.EndSegment();
            }
@lupengamzn
Copy link
Contributor

Hi @jon-armen ,

Thank you for bringing this up

This is indeed an edge case issue in X-Ray SDK while serializing duplicate exception. In the second catch statement, as the AmazonServiceException from previous step has already been recorded, SDK will only record the Cause to the exception descriptor. When the AmazonServiceException is wrapped as an inner exception and passed to next catch statement, the SDK will try to figure out if this inner exception has been recorded or not by checking the Exception from the descriptor, which, as I mentioned before, will not be recorded as only the Cause will be recorded for duplicate exception. This is why you see the null reference exception.

We'll work on this and get it fixed soon.

@jon-armen
Copy link
Contributor Author

Awesome, thank you @lupengamzn . If it helps, I submitted #210 as a potential fix.

@jon-armen
Copy link
Contributor Author

@lupengamzn , @srprash - Any updates on when we might be able to get a release generated with the current codebase? I would really like to get this fix into our production environments.

@srprash
Copy link
Collaborator

srprash commented Jul 14, 2022

Released in v2.11.0

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

3 participants