Skip to content

Commit

Permalink
Made code more resilient. (#2031)
Browse files Browse the repository at this point in the history
Made code more resilient. Somehow it can happen that task.request.get("headers", {}) returned None.
  • Loading branch information
antonpirker authored Apr 25, 2023
1 parent 3255a93 commit a2e1288
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ def sentry_workloop(*args, **kwargs):

def _get_headers(task):
# type: (Task) -> Dict[str, Any]
headers = task.request.get("headers", {})
headers = task.request.get("headers") or {}

# flatten nested headers
if "headers" in headers:
headers.update(headers["headers"])
del headers["headers"]

headers.update(task.request.get("properties", {}))
headers.update(task.request.get("properties") or {})

return headers

Expand Down

0 comments on commit a2e1288

Please sign in to comment.