Skip to content

Downgrade routine anon-403s on /api/v3/auth/profile/ to DEBUG#759

Merged
ajslater merged 1 commit into
developfrom
claude/downgrade-noisy-403-log
May 10, 2026
Merged

Downgrade routine anon-403s on /api/v3/auth/profile/ to DEBUG#759
ajslater merged 1 commit into
developfrom
claude/downgrade-noisy-403-log

Conversation

@ajslater
Copy link
Copy Markdown
Owner

Summary

Cuts down log noise from every first-time visitor.

A fresh browser hits /api/v3/auth/profile/ before any session cookie exists, which Django's BaseHandler.get_response logs as WARNING: Forbidden: /api/v3/auth/profile/ for every visit. That drowns the main log with routine first-load behaviour.

This adds a logging.Filter on the django.request logger that downgrades records matching "Forbidden: <noisy-path>" to DEBUG. The noisy-path list is a frozenset constant, so adding a future endpoint is a one-line change.

Originating from review feedback after the failed-login log PR (#757) — true abuse of /profile/ is unlikely to matter for fail2ban, and a brute-forcer would surface in failed_logins.log first regardless.

Also fixes a latent config bug

codex/settings/logging.py had django.request, django, and django.server declared at the top level of the LOGGING dict, but Python's dictConfig only recognises "loggers" as the container for named loggers — those blocks were silently ignored. Records were still reaching the root loguru handler via propagation, but no per-logger filter could be attached.

django.request is now moved into the loggers dict (where the new filter lives). Left django and django.server alone to keep this diff focused; happy to clean them up in a follow-up.

Test plan

  • make fix && make lint && make ty clean
  • pytest tests/test_logging_filter.py -v — 4 tests cover the noisy path, an unrelated Forbidden path (stays WARNING), a non-Forbidden 4xx (stays WARNING), and non-WARNING levels (untouched)
  • make test-python — full suite still passes (231 total)
  • Manual: visit Codex with a clean browser, confirm no Forbidden: /api/v3/auth/profile/ WARNING appears in codex.log at default INFO level

🤖 Generated with Claude Code

A fresh browser visit to Codex probes /api/v3/auth/profile/ before any
session cookie exists, which Django's BaseHandler.get_response logs as
a WARNING ("Forbidden: /api/v3/auth/profile/") for every first-time
visitor. That drowns the main log in routine noise.

Add a logging.Filter on django.request that downgrades records matching
that exact "Forbidden: <path>" pattern to DEBUG, parameterized by a
small frozenset of known-noisy paths so abuse on other endpoints still
surfaces at WARNING.

Also move django.request into the loggers dict where dictConfig will
actually see it — the old top-level placement was silently ignored.
Records still flow to the root loguru handler via propagation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ajslater ajslater merged commit f16dab1 into develop May 10, 2026
3 checks passed
@ajslater ajslater deleted the claude/downgrade-noisy-403-log branch May 11, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant