Skip to content

Commit fbd5983

Browse files
Fix(dotnet) Add Null safety to doc (#14637)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR *Tell us what you're changing and why. If your PR **resolves an issue**, please link it so it closes automatically.* Fix `Value cannot be null. (Parameter 'bytes')` when users copy/paste this code into their servers. This happens because on the same doc, those values can be null ``` properties.Headers.Add("sentry-trace", SentrySdk.GetTraceHeader()?.ToString()); properties.Headers.Add("baggage", SentrySdk.GetBaggage()?.ToString()); ``` So we add some null checks before retrieving the trace or baggage and everyone gets happy!. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Bruno Garcia <[email protected]>
1 parent cb8fd54 commit fbd5983

File tree

1 file changed

+2
-2
lines changed
  • platform-includes/distributed-tracing/custom-instrumentation

1 file changed

+2
-2
lines changed

platform-includes/distributed-tracing/custom-instrumentation/dotnet.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ consumer.Received += (model, ea) =>
3333
var sentryTraceHeader = string.Empty;
3434
var sentryBaggageHeader = string.Empty;
3535

36-
if (headers.TryGetValue("sentry-trace", out var traceHeader))
36+
if (headers.TryGetValue("sentry-trace", out var traceHeader) && traceHeader is not null)
3737
{
3838
sentryTraceHeader = Encoding.UTF8.GetString((byte[])traceHeader);
3939
}
4040

41-
if (headers.TryGetValue("baggage", out var baggageHeader))
41+
if (headers.TryGetValue("baggage", out var baggageHeader) && baggageHeader is not null)
4242
{
4343
sentryBaggageHeader = Encoding.UTF8.GetString((byte[])baggageHeader);
4444
}

0 commit comments

Comments
 (0)