From 393d4dbb6722e74560fb14214aeab2ac5b51deae Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 8 Sep 2026 12:45:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=87(backend)=20silence=20expected=2040?= =?UTF-8?q?1=20warnings=20on=20/me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a busy morning, `/me` alone produced 72k warning logs — 97% of all warnings. They all come from anonymous requests to `/me` without credentials, which is normal: `/me` is how the app determines the current auth status. These warnings carry no diagnostic value on this endpoint, so silence them there to cut down on log volume. --- CHANGELOG.md | 4 ++++ src/backend/core/logging_filters.py | 21 +++++++++++++++++++++ src/backend/meet/settings.py | 6 ++++++ 3 files changed, 31 insertions(+) create mode 100644 src/backend/core/logging_filters.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 38637535..623cf972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to - 🔒️(backend) enforce display name setting on rename API +### Changed + +- 🔇(backend) silence expected 401 warnings on /me + ## [1.31.0] - 2026-09-08 ### Added diff --git a/src/backend/core/logging_filters.py b/src/backend/core/logging_filters.py new file mode 100644 index 00000000..1e0bf7e3 --- /dev/null +++ b/src/backend/core/logging_filters.py @@ -0,0 +1,21 @@ +"""Logging filters for the core application.""" + +import logging + + +class SilenceExpected401(logging.Filter): + """Drop the expected 401 from anonymous hits on the /me endpoint. + + The frontend probes `/users/me/` to check authentication; a 401 for + anonymous users is normal, not a warning worth logging. + """ + + def filter(self, record): + """Return False for a 401 on `/users/me`.""" + if getattr(record, "status_code", None) == 401: + request = getattr(record, "request", None) + path = getattr(request, "path", "") or "" + if path.rstrip("/").endswith("/users/me"): + return False + + return True diff --git a/src/backend/meet/settings.py b/src/backend/meet/settings.py index d434a554..468642f5 100755 --- a/src/backend/meet/settings.py +++ b/src/backend/meet/settings.py @@ -1122,10 +1122,16 @@ class Base(Configuration): "style": "{", }, }, + "filters": { + "silence_expected_401": { + "()": "core.logging_filters.SilenceExpected401", + }, + }, "handlers": { "console": { "class": "logging.StreamHandler", "formatter": "simple", + "filters": ["silence_expected_401"], }, }, # Override root logger to send it to console