fix: handle missing span description and empty webhook URL#119452
Draft
billyvg wants to merge 1 commit into
Draft
fix: handle missing span description and empty webhook URL#119452billyvg wants to merge 1 commit into
billyvg wants to merge 1 commit into
Conversation
- 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
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.
Fixes two high/medium severity production errors surfaced by Sentry alerts.
SENTRY-5QVD —
KeyError: 'description'in MN+1 DB span detector (219k+ events, high actionability)Root cause:
mn_plus_one_db_span_detector.pyline 258 accesseddb_span["description"]directly. Certain span payloads (observed in thederegion) lack adescriptionkey, causing aKeyErrorthat bubbles up asFailed to detect performance problemsand 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:
spans.consumers.process_segments.process_segmentSENTRY-5HAE —
MissingSchema: Invalid URL ''in sentry app webhook sender (178k+ events, medium actionability)Root cause:
send_and_save_webhook_requestfalls back tosentry_app.webhook_urlwhen no URL override is provided (line 256:url = url or sentry_app.webhook_url). When a sentry app has an empty string webhook URL, theassert url is not Noneguard on line 267 passes (empty string is not None), andsafe_urlopen("")raisesrequests.exceptions.MissingSchemarather than halting cleanly.Fix: After resolving
url, checkif not url:and halt the lifecycle with the newSentryAppWebhookHaltReason.MISSING_URLreason. 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:
sentry.sentry_apps.tasks.sentry_apps.send_alert_webhook_v2Changes
src/sentry/issue_detection/detectors/mn_plus_one_db_span_detector.pydb_span.get("description", "")instead ofdb_span["description"]src/sentry/utils/sentry_apps/webhooks.pyif not url:→ halt withMISSING_URLsrc/sentry/sentry_apps/metrics.pyMISSING_URL = "missing_url"toSentryAppWebhookHaltReasonenumSession: 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