fix: handle missing description key in MN+1 DB span detector#119484
Closed
billyvg wants to merge 1 commit into
Closed
fix: handle missing description key in MN+1 DB span detector#119484billyvg wants to merge 1 commit into
billyvg wants to merge 1 commit into
Conversation
Spans in the process-segments consumer may lack a `description` field,
causing KeyError in `_maybe_performance_problem`. Use `.get("description", "")`
to gracefully handle spans without this field.
Fixes SENTRY-5QVD
Contributor
Backend Test FailuresFailures on
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a
KeyError: 'description'crash in the MN+1 DB span detector that has been firing 333K+ times since 2026-06-25, affecting theprocess-segmentsconsumer in production.Root cause:
ContinuingMNPlusOne._maybe_performance_problem()accesseddb_span["description"]directly. Spans processed by the standalone segment pipeline (spans.consumers.process_segments) may not include adescriptionfield, causing an unhandledKeyErrorthat swallowed the entire performance detection step via a broadexceptindetect_performance_problems.Fix: Replace
db_span["description"]withdb_span.get("description", "")in both places in_maybe_performance_problem()— once for thePerformanceProblem.descfield and once for theevidence_displaynotification body.Evidence
mn_plus_one_db_span_detector.py:258in_maybe_performance_problem.get('description', '')to safely access the db span description"Changes
src/sentry/issue_detection/detectors/mn_plus_one_db_span_detector.py: Use.get("description", "")instead of direct key access in two placestests/sentry/issue_detection/test_m_n_plus_one_db_detector.py: Addtest_does_not_raise_when_db_span_missing_description— verifies the detector returns a problem withdesc=""instead of crashingClaude Session
https://claude.ai/code/session_01KBB4d6THmfZynYkkcPNxTh
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
Generated by Claude Code