Skip to content

W3CBaggagePropagator fails to extract baggage when header name is title-cased (e.g., "Baggage" vs "baggage") #4106

Description

@oszlak

Describe your environment

  • OS: Amazon Linux 2 (AWS Lambda)
  • Python version: 3.11
  • SDK version: opentelemetry-sdk==1.33.0
  • Relevant packages: opentelemetry-instrumentation-aws-lambda

What happened?

The W3CBaggagePropagator fails to extract baggage context when the HTTP header name is title-cased (Baggage) instead of lowercase (baggage). This occurs when requests pass through AWS API Gateway, which normalizes header names to title case.

Per RFC 7230 and the W3C Baggage specification, HTTP header names are case-insensitive. The propagator should perform case-insensitive header lookup.

Steps to Reproduce

  1. Deploy a Python Lambda function with OpenTelemetry instrumentation and W3CBaggagePropagator
  2. Send a request with baggage header via two different methods:
    • Method A: Via AWS API Gateway (e.g., using k6 load test tool)
    • Method B: Via AWS Lambda Test UI (direct invocation)
  3. Observe that baggage extraction works in one case but not the other

Expected Result

Baggage should be extracted regardless of header name casing (baggage, Baggage, BAGGAGE, etc.)

Actual Result

Via AWS Lambda Test UI (works) - header stays lowercase:

Request headers: {'baggage': 'city_id=123456,env=MY_ENV,root_endpoint=my-service-handler'}
Extracted baggage: {'city_id': '123456', 'env': 'MY_ENV', 'root_endpoint': 'my-service-handler'}

Via API Gateway with k6 (fails) - header is title-cased:

Request headers: {'Baggage': 'city_id=123456,env=MY_ENV,root_endpoint=my-service-handler'}
Extracted baggage: {}  # Empty - baggage not extracted

AWS API Gateway normalizes HTTP header names to title case (baggageBaggage), causing the extraction to fail.

Additional context

No response

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions