Skip to content

Commit b588faa

Browse files
Fix trace state parsing. (#638)
- Without this the `.Value<string>` was exploding attempting to convert to a string.
1 parent bcb734c commit b588faa

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/JsonRpc/Receiver.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,25 @@ protected virtual Renor GetRenor(JToken @object)
100100

101101
var properties = request.Properties().ToLookup(z => z.Name, StringComparer.OrdinalIgnoreCase);
102102

103+
var traceStateProperty = properties["tracestate"].FirstOrDefault();
104+
var traceState = traceStateProperty?.Value.ToString();
105+
var traceParentProperty = properties["traceparent"].FirstOrDefault();
106+
var traceParent = traceParentProperty?.Value.ToString();
107+
103108
// id == request
104109
// !id == notification
105110
if (!hasRequestId)
106111
{
107112
return new Notification(method!, @params) {
108-
TraceState = properties["tracestate"].FirstOrDefault()?.Value<string>(),
109-
TraceParent = properties["traceparent"].FirstOrDefault()?.Value<string>()
113+
TraceState = traceState,
114+
TraceParent = traceParent,
110115
};
111116
}
112117
else
113118
{
114119
return new Request(requestId!, method!, @params) {
115-
TraceState = properties["tracestate"].FirstOrDefault()?.Value<string>(),
116-
TraceParent = properties["traceparent"].FirstOrDefault()?.Value<string>()
120+
TraceState = traceState,
121+
TraceParent = traceParent,
117122
};
118123
}
119124
}

0 commit comments

Comments
 (0)