fix(celery): coerce non-string values in CeleryGetter.get()#4360
Open
DrMeers wants to merge 3 commits intoopen-telemetry:mainfrom
Open
fix(celery): coerce non-string values in CeleryGetter.get()#4360DrMeers wants to merge 3 commits intoopen-telemetry:mainfrom
DrMeers wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
Celery's Context copies all message properties as instance attributes via __dict__.update(), including non-string values like timelimit (tuple of ints) and priority (int). The TextMapPropagator contract requires string values from Getter.get(), but CeleryGetter returned these non-string values as-is, causing TraceState.from_header() to crash with TypeError when calling re.split() on an int. Coerce all non-string values to strings before returning them. See open-telemetry#4359
7 tasks
tammy-baylis-swi
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CeleryGetter.get()can return non-string values (e.g.int) from Celery task request attributes, which causesTraceState.from_header()to crash withTypeError: expected string or bytes-like object, got 'int'.Celery's
Contextcopies all message properties as instance attributes via__dict__.update(), including non-string values liketimelimit(tuple of ints) andpriority(int). TheTextMapPropagatorcontract requires string values fromGetter.get(), butCeleryGetterreturned these non-string values as-is.This patch coerces all non-string values to strings before returning them.
Fixes #4359
Type of change
How Has This Been Tested?
test_get_iterassertion (now returns tuple, consistent with coercion)Does This PR Require a Core Repo Change?
Checklist: