Skip to content
New issue

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

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

Already on GitHub? # to your account

Prevent NullReferenceException in SentryTraceHeader Parsing #3757

Conversation

Victorvhn
Copy link
Contributor

Hey y'all,

I recently encountered an issue where nearly every API request threw an exception after integrating Sentry with OpenTelemetry in my APIs. This issue only affected my environment, likely due to having Just My Code disabled in debugging options.

Upon investigation, I discovered that a null value was being passed to the Parse method in SentryTraceHeader.cs. The method was attempting to call .Split() on this null value, leading to an NullReferenceException.

To address this, I added a null check in the Parse method before calling .Split().

Please review the changes when you have a chance and let me know if there are any additional adjustments or improvements you’d like to see. Thank you!


Moved from PR

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (version-5.0.0@ec3e21f). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             version-5.0.0    #3757   +/-   ##
================================================
  Coverage                 ?   76.54%           
================================================
  Files                    ?      381           
  Lines                    ?    13997           
  Branches                 ?     2818           
================================================
  Hits                     ?    10714           
  Misses                   ?     2595           
  Partials                 ?      688           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason you picked v5 branch for this fix? Would be great to put this out there for v4 too.

Oh, because it's a breaking change it seems?

@Victorvhn
Copy link
Contributor Author

Any particular reason you picked v5 branch for this fix? Would be great to put this out there for v4 too.

Oh, because it's a breaking change it seems?

Yeah, I guess it’s because I’m changing the signature of a public method. So the team asked me to open it to v5 instead of main. But I think it will be released soon since v5 will add support for .NET 9

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big thank you for the PR @Victorvhn and for fussing around with the branches. Much appreciated!

@jamescrosswell jamescrosswell merged commit ed36c19 into getsentry:version-5.0.0 Nov 17, 2024
18 checks passed
@Victorvhn Victorvhn deleted the fix/prevent-null-reference-sentry-trace-header-parser-on-v5 branch November 17, 2024 20:51
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants