File tree Expand file tree Collapse file tree
sentry_sdk/integrations/celery Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments