Baggage value certain characters will crash application or encode chars
See original GitHub issueBug Report
<PackageReference Include="OpenTelemetry.Api" Version="1.0.0-rc1.1" />
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.0.0-rc1.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc1.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc1.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc1.1" />
- Runtime version:
netcoreapp3.1
Symptom
When adding Baggage
to an Activity
using certain chars will encode them or crash the receiving application.
The baggage value is not correctly received in child-service.
Char | Result |
---|---|
\ |
%2B |
@ |
%2540 |
, |
%252C |
& |
%2526 |
( |
Will crash the ASP.NET Core Service |
(only some samples) |
There is no mentioning of a limited allowed charset in specification/overview.md#baggage ?
What is the expected behavior?
Original baggage value should be preserved exactly.
What is the actual behavior?
Some characters are only encoded.
Using round brackets will crash the ASP.NET Core WEB API Service.
Using .AddBaggage("demo.foobar5", "!x_x,x-x&x(x");
:
[2020-11-22 15:23:48Z ERR] Connection id "0HM4EVAE30FTQ", Request id "0HM4EVAE30FTQ:00000001":
An unhandled exception was thrown by the application. System.FormatException: The format of
value '!x_x%2Cx-x%26x(x' is invalid.
at System.Net.Http.Headers.NameValueHeaderValue.CheckValueFormat(String value)
at System.Net.Http.DiagnosticsHandler.InjectHeaders(Activity currentActivity, HttpRequestMessage request)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at FrontendService.Controllers.WeatherFrontendController.GetWeatherForecast() in D:xxxxxxxxxxxxx:line 109
Reproduce
Activity.Current?
.AddBaggage("demo.foobar1", "demouser")
.AddBaggage("demo.foobar2", "demo user")
.AddBaggage("demo.foobar3", @"domain\demouser")
.AddBaggage("demo.foobar4", "user@example.com")
.AddBaggage("demo.foobar5", "!x_x,x-x&x(x"); // Will cause exception in receiving service
In child-service:
if (Activity.Current?.Baggage != null)
{
foreach (var bag in Activity.Current.Baggage)
{
_logger.LogInformation("Found Baggage {BaggageKey}={BaggageValue}", bag.Key, bag.Value);
// Use baggage data in tag which will be stored in jaeger
Activity.Current.SetTag($"ax.debug.{bag.Key}", bag.Value);
}
}
Log output of receiving service
Found Baggage demo.foobar4=user%2540example.com
Found Baggage demo.foobar3=domain%255Cdemouser
Found Baggage demo.foobar2=demo%2Buser
Found Baggage demo.foobar1=demouser
Resulting display in jaeger 1.21.0
:
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why One-Hot Encode Data in Machine Learning?
In this post, you discovered why categorical data often must be encoded when working with machine learning algorithms. Specifically: That ...
Read more >How to turn Text into Features
The Bag of Words (BoW) Model. One hot encoding only treats values as “present” and “not present”. That's not appropriate for text. In...
Read more >The HTTP crash course nobody asked for - fasterthanli.me
It merely involves opening a TCP connection to some server, ... almost sent a non-ASCII character there, can't have that in a header...
Read more >C/C++ Char Pointer Crash
This is the case usually because the string itself is hardcoded along with the code of your application. When loading, pointers are stablished ......
Read more >Guidelines for Performance Monitoring
This document covers how SDKs should add support for Performance Monitoring with Distributed Tracing . This should give an overview of the APIs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Got similar behavior when tried to pass baggage between services. Set baggage like this:
Get baggage:
I see the encoding in inject method, but there is no decoding in the extract method.
So probably it could be easily fixed if we add decoding into the extract method.
That seems to be the correct route since the DiagnosticListener in the runtime is automatically going to add anything on Activity.Baggage. I haven’t tried yet, yesterday we just switched out baggage to tag to get OTEL enabled again. Today, I’ll get something into prod with the OTEL Baggage API.