Skip to content

Add KeyError to ignored exceptions#161

Open
mendral-app[bot] wants to merge 1 commit into
mainfrom
mendral/add-keyerror-ignored-exceptions
Open

Add KeyError to ignored exceptions#161
mendral-app[bot] wants to merge 1 commit into
mainfrom
mendral/add-keyerror-ignored-exceptions

Conversation

@mendral-app

@mendral-app mendral-app Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add KeyError and AttributeError to _IGNORED_EXCEPTIONS in the Sentry trace handler to eliminate false-positive reports from dict-like __getitem__ methods and hasattr/getattr patterns (EAFP style)
  • Fixes noise from 4 spurious KeyError events reported to Sentry during test runs with MagicMock objects

Related insight: https://app.mendral.com/insights/01KTSHD0ZDFZ2AAENVZ8TA55MT


Note

Created by Mendral. Tag @mendral-app with feedback or questions.

KeyError and AttributeError are normal control-flow exceptions in Python
(EAFP pattern, dict-like __getitem__, hasattr/getattr). They should not
be reported to Sentry by the sys.settrace handler.

This eliminates false-positive KeyError reports from dict-like model
classes (e.g. DriveMountInfo.__getitem__) during test runs.
@mendral-app mendral-app Bot requested a review from a team June 10, 2026 19:51
@mendral-app mendral-app Bot marked this pull request as ready for review June 10, 2026 20:01
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.

0 participants