Skip to content

fix: handle missing span description and empty webhook URL#119452

Draft
billyvg wants to merge 1 commit into
masterfrom
claude/serene-cannon-cp38yy
Draft

fix: handle missing span description and empty webhook URL#119452
billyvg wants to merge 1 commit into
masterfrom
claude/serene-cannon-cp38yy

Conversation

@billyvg

@billyvg billyvg commented Jul 11, 2026

Copy link
Copy Markdown
Member

Fixes two high/medium severity production errors surfaced by Sentry alerts.

SENTRY-5QVDKeyError: 'description' in MN+1 DB span detector (219k+ events, high actionability)

Root cause: mn_plus_one_db_span_detector.py line 258 accessed db_span["description"] directly. Certain span payloads (observed in the de region) lack a description key, causing a KeyError that bubbles up as Failed to detect performance problems and silently skips performance problem detection for those segments.

Fix: db_span.get("description", "") — consistent with how other span fields (e.g. transaction_name) are read defensively throughout the same file.

Evidence:


SENTRY-5HAEMissingSchema: Invalid URL '' in sentry app webhook sender (178k+ events, medium actionability)

Root cause: send_and_save_webhook_request falls back to sentry_app.webhook_url when no URL override is provided (line 256: url = url or sentry_app.webhook_url). When a sentry app has an empty string webhook URL, the assert url is not None guard on line 267 passes (empty string is not None), and safe_urlopen("") raises requests.exceptions.MissingSchema rather than halting cleanly.

Fix: After resolving url, check if not url: and halt the lifecycle with the new SentryAppWebhookHaltReason.MISSING_URL reason. This surfaces the configuration problem as a structured halt instead of an unhandled exception, and avoids polluting error tracking with noise from misconfigured apps.

Evidence:


Changes

File Change
src/sentry/issue_detection/detectors/mn_plus_one_db_span_detector.py db_span.get("description", "") instead of db_span["description"]
src/sentry/utils/sentry_apps/webhooks.py Guard if not url: → halt with MISSING_URL
src/sentry/sentry_apps/metrics.py Add MISSING_URL = "missing_url" to SentryAppWebhookHaltReason enum

Session: https://claude.ai/code/session_015nUsqCoG5gXgQM8FLTigMk

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

- SENTRY-5QVD: use .get() on db_span description in MNPlusOneDBSpanDetector
  to avoid KeyError when spans lack a description field (219k+ events)
- SENTRY-5HAE: guard against empty webhook_url in send_and_save_webhook_request
  to avoid MissingSchema from requests instead of halting gracefully (178k+ events)
- Add MISSING_URL to SentryAppWebhookHaltReason enum to support the new halt path
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 11, 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.

2 participants