Skip to content

fix: handle missing description key in MN+1 DB span detector#119488

Closed
billyvg wants to merge 1 commit into
mainfrom
claude/serene-cannon-wpk5wh
Closed

fix: handle missing description key in MN+1 DB span detector#119488
billyvg wants to merge 1 commit into
mainfrom
claude/serene-cannon-wpk5wh

Conversation

@billyvg

@billyvg billyvg commented Jul 13, 2026

Copy link
Copy Markdown
Member

Problem

ContinuingMNPlusOne._maybe_performance_problem() crashes with KeyError: 'description' when processing downsampled spans that don't include a description field.

This has been firing at high volume in production: 335K total occurrences (44K in the past 24h), all from spans.consumers.process_segments.process_segment. Sentry issue: SENTRY-5QVD.

The error manifests as a logged exception ("Failed to detect performance problems") caught in performance_detection.py:141, so it silently skips performance problem detection for affected spans.

Root cause

The event data from the local variables in the Sentry issue shows spans with "downsampled_retention_days" set but no description key — evidence that downsampled spans may omit optional fields. Two call sites accessed db_span["description"] directly:

  • desc=db_span["description"] (line 258)
  • get_notification_attachment_body("db", db_span["description"]) (line 283)

Fix

Switch both accesses to .get("description", ""). All other span dict accesses in this file already use .get() safely.

Evidence / Reasoning

From the Sentry event's local variables:

common_parent_span: {"downsampled_retention_days":"30", ...}
offender_db_spans: [{"downsampled_retention_days":"30", ...]

The description field is missing from downsampled spans, confirming this is a data-shape issue rather than a logic bug. The fix is minimal and defensive.


Claude session: https://claude.ai/code/session_014nmqRhMsbDqY6YwD21UA8e

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

Downsampled spans do not always include a 'description' field,
causing KeyError crashes (335K occurrences, Fixes SENTRY-5QVD).

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 13, 2026
@manessaraj manessaraj deleted the branch main July 13, 2026 13:47
@manessaraj manessaraj closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants