Skip to content

Commit 9e59ee5

Browse files
Update sentry_sdk/integrations/celery/__init__.py
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1a31c9b commit 9e59ee5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

sentry_sdk/integrations/celery/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,12 @@ def _update_celery_task_headers(
233233

234234
# Preserve user-provided custom headers in the inner "headers" dict
235235
# so they survive to task.request.headers on the worker (celery#4875).
236-
for key, value in original_headers.items():
237-
if key != "headers" and key not in updated_headers["headers"]:
238-
updated_headers["headers"][key] = value
236+
# Preserve user-provided custom headers in the inner "headers" dict
237+
# so they survive to task.request.headers on the worker (celery#4875).
238+
inner_headers = updated_headers.setdefault("headers", {})
239+
for key, value in original_headers.items():
240+
if key != "headers" and key not in inner_headers:
241+
inner_headers[key] = value
239242

240243
return updated_headers
241244

0 commit comments

Comments
 (0)