Skip to content

fix(celery): coerce non-string values to str in CeleryGetter.get()#4434

Closed
alliasgher wants to merge 2 commits intoopen-telemetry:mainfrom
alliasgher:fix-celery-getter-non-string
Closed

fix(celery): coerce non-string values to str in CeleryGetter.get()#4434
alliasgher wants to merge 2 commits intoopen-telemetry:mainfrom
alliasgher:fix-celery-getter-non-string

Conversation

@alliasgher
Copy link
Copy Markdown

@alliasgher alliasgher commented Apr 14, 2026

Description

CeleryGetter.get() previously returned header values verbatim. When a downstream library sets a non-string value in the header map (e.g. an int), propagator machinery downstream fails because it expects str. Coerce non-string values with str() so context propagation is robust.

Fixes #4341

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Changelog entry added under Unreleased / Fixed

Celery's Context object copies all message properties as instance attrs,
including numeric fields like timelimit. CeleryGetter.get() wrapped these
in a tuple but didn't convert to str, causing TextMapPropagators to crash
with "TypeError: expected string or bytes-like object, got 'int'" when
calling re.split() in TraceState.from_header().

Coerce non-string, non-iterable values to str before wrapping in a tuple.

Fixes open-telemetry#4359

Signed-off-by: alliasgher <alliasgher123@gmail.com>
@alliasgher alliasgher force-pushed the fix-celery-getter-non-string branch from ee15d7b to f9ee765 Compare April 15, 2026 20:17
Signed-off-by: Ali <alliasgher123@gmail.com>
@alliasgher alliasgher requested a review from a team as a code owner April 15, 2026 20:21
@MikeGoldsmith
Copy link
Copy Markdown
Member

This is a duplicate of #4360. Closing this one in favour of that one as it's already approved. Thanks @alliasgher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants