Skip to content

Remove email notifications for exceptions, route to Sentry only#6001

Merged
DonnieBLT merged 2 commits intomainfrom
copilot/update-email-notification-handling
Mar 10, 2026
Merged

Remove email notifications for exceptions, route to Sentry only#6001
DonnieBLT merged 2 commits intomainfrom
copilot/update-email-notification-handling

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Django's AdminEmailHandler was configured alongside Sentry, causing exceptions to be emailed to admins redundantly. Sentry already captures all exceptions via sentry_sdk with DjangoIntegration.

Changes

  • blt/settings.py: Removed mail_admins handler (django.utils.log.AdminEmailHandler) from LOGGING and dropped it from the django logger's handler list
# Before
"handlers": {
    "console": { ... },
    "mail_admins": {"level": "ERROR", "class": "django.utils.log.AdminEmailHandler"},
},
"loggers": {
    "django": {
        "handlers": ["console", "mail_admins"],
        ...
    },

# After
"handlers": {
    "console": { ... },
},
"loggers": {
    "django": {
        "handlers": ["console"],
        ...
    },

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Copilot AI changed the title [WIP] Update exception handling to send notifications to Sentry Remove email notifications for exceptions, route to Sentry only Mar 10, 2026
@DonnieBLT DonnieBLT marked this pull request as ready for review March 10, 2026 03:10
Copilot AI review requested due to automatic review settings March 10, 2026 03:10
@github-actions github-actions bot added files-changed: 1 unresolved-conversations: 0 PR has 0 unresolved conversations labels Mar 10, 2026
@DonnieBLT DonnieBLT merged commit bea7de5 into main Mar 10, 2026
14 checks passed
@DonnieBLT DonnieBLT deleted the copilot/update-email-notification-handling branch March 10, 2026 03:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes Django’s admin exception email logging so that exceptions are reported via Sentry only, avoiding redundant notifications.

Changes:

  • Removed the django.utils.log.AdminEmailHandler (mail_admins) handler from LOGGING.
  • Updated the django logger to no longer reference mail_admins.

Comment on lines 445 to 447
"django": {
"handlers": ["console", "mail_admins"],
"handlers": ["console"],
"level": "INFO",
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With mail_admins removed from the django logger, production exception notifications will now rely entirely on Sentry. Since sentry_sdk.init(...) is conditional on SENTRY_DSN being set, environments without SENTRY_DSN configured will no longer emit any exception alerts. Consider enforcing SENTRY_DSN when DEBUG is False (fail fast) or adding an explicit fallback handler for error-level logs in non-debug environments.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot added pre-commit: passed Pre-commit checks passed tests: P:636 F:0 S:0 Django tests passed labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

files-changed: 1 pre-commit: passed Pre-commit checks passed tests: P:636 F:0 S:0 Django tests passed unresolved-conversations: 0 PR has 0 unresolved conversations

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants