diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index 3e0c58ae44..049708743a 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -447,7 +447,11 @@ def sentry_publish(self, *args, **kwargs): # type: (Producer, *Any, **Any) -> Any kwargs_headers = kwargs.get("headers", {}) if not isinstance(kwargs_headers, Mapping): - # Ensure kwargs_headers is a Mapping, so we can safely call get() + # Ensure kwargs_headers is a Mapping, so we can safely call get(). + # We don't expect this to happen, but it's better to be safe. Even + # if it does happen, only our instrumentation breaks. This line + # does not overwrite kwargs["headers"], so the original publish + # method will still work. kwargs_headers = {} task_name = kwargs_headers.get("task")