From 212afe0e36a94501c1f003550d65d5961db1c822 Mon Sep 17 00:00:00 2001 From: Dan LaManna Date: Fri, 2 Oct 2026 11:22:26 -0400 Subject: [PATCH] Ignore gunicorn's warning about HEAD response bodies gunicorn 26.1.0 and later drop the body of a HEAD response and log a warning for each one. Django returns the full body for HEAD requests, so every HEAD request to a view sends this warning to Sentry. The filter keeps the same warning for 204, 304 and 1xx responses, because a body there is a bug in the view. --- isic/settings/_sentry_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/isic/settings/_sentry_utils.py b/isic/settings/_sentry_utils.py index 5401f60a..aa4c487d 100644 --- a/isic/settings/_sentry_utils.py +++ b/isic/settings/_sentry_utils.py @@ -21,6 +21,16 @@ def filter_sentry_event(event: Event, hint: Hint) -> Event | None: ): return None + # Django returns the full body for HEAD requests. gunicorn drops the body, but logs a + # warning on every such request. + if ( + log_record is not None + and log_record.name == "gunicorn.http.wsgi" + and "RFC 9110" in log_record.getMessage() + and "method=HEAD " in log_record.getMessage() + ): + return None + return event