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

Baggage member values are not being decoded when extracted from carriers #2519

Closed
williamgcampbell opened this issue Jan 18, 2022 · 0 comments · Fixed by #2529
Closed

Baggage member values are not being decoded when extracted from carriers #2519

williamgcampbell opened this issue Jan 18, 2022 · 0 comments · Fixed by #2529
Labels
bug Something isn't working

Comments

@williamgcampbell
Copy link

Description

According to the spec, Baggage header values should be encoded in transit.

The Baggage propagator appears to be encoding Baggage Member values on Inject but never decoding them on Extract. For multiple passive hops, the Baggage Member value will continue getting encoded.

Environment

  • OS: linux/mac
  • Architecture: x86_64
  • Go Version: 1.17
  • opentelemetry-go version: v1.2.0

Steps To Reproduce

  1. Set a baggage header with a member value that requires encoding
  2. Pass the baggage through multiple Inject/Extracts of the Baggage propagator.

Here's a test to demonstrate the behavior in isolation:

func TestBaggage(t *testing.T) {
	propagator := propagation.Baggage{}
	hc := propagation.HeaderCarrier{}
	hc.Set("baggage", "myKey=1%3D1")

	want := "1%3D1"
        ctx := context.Background()

	ctx = propagator.Extract(ctx, hc)
	actual := baggage.FromContext(ctx).Member("myKey").Value()
	require.Equal(t, want, actual)

        // inject will encode the '%' literal from the already encoded value
	propagator.Inject(ctx, hc)

	ctx = propagator.Extract(ctx, hc)
	actual = baggage.FromContext(ctx).Member("myKey").Value()
	require.Equal(t, want, actual) // fail
}

Expected behavior

The Baggage Member value should be decoded when being extracted onto the Context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant