fix: guard against None target_type in WorkflowEngineActionSerializer and missing description in MNPlusOne detector#119451
Draft
billyvg wants to merge 1 commit into
Draft
fix: guard against None target_type in WorkflowEngineActionSerializer and missing description in MNPlusOne detector#119451billyvg wants to merge 1 commit into
billyvg wants to merge 1 commit into
Conversation
…an detectors Fix two production errors: 1. SENTRY-5NQG: WorkflowEngineActionSerializer crashes with ValueError when serializing webhook actions that have no target_type (None). Guard the ActionTarget() call with a None check so webhook actions serialize cleanly with targetType=None. 2. SENTRY-5QVD: MNPlusOneDBSpanDetector crashes with KeyError when a db span is missing the 'description' key (new span schema emits downsampled_retention_days instead). Use .get() with empty-string default so detection continues instead of raising. Fixes SENTRY-5NQG Fixes SENTRY-5QVD Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SibgpfAgzvJRtry63iYB3c
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 production errors surfaced by automated Sentry alert monitoring.
Claude session: https://claude.ai/code/session_01SibgpfAgzvJRtry63iYB3c
Fix 1: SENTRY-5NQG —
ValueError: None is not a valid ActionTarget(medium severity)Issue:
SENTRY-5NQG— 6,500+ events, ongoing since Apr 22Root cause:
WorkflowEngineActionSerializercallsActionTarget(target_type)wheretarget_typeisNonefor webhook-type actions (they have no target). The enum constructor raisesValueError: None is not a valid ActionTarget, which propagates throughSentryAppMetricAlertHandler → invoke_legacy_registry → get_incident_serializer, causing metric alert webhook notifications to silently fail to serialize.Fix: Guard the
ActionTarget()call with aNonecheck, returningNonefortargetTypewhen no target type is configured — consistent with howdescis already handled on the line below it.Files changed:
src/sentry/incidents/endpoints/serializers/workflow_engine_action.pyFix 2: SENTRY-5QVD —
KeyError: 'description'in MNPlusOne DB span detector (medium severity)Issue:
SENTRY-5QVD— 213k+ events, ongoing since Jun 25Root cause:
ContinuingMNPlusOne._maybe_performance_problem()accessesdb_span["description"]directly. New span schema (spans emittingdownsampled_retention_daysrather than the standard span fields) causes some spans to arrive without adescriptionkey. TheKeyErroris caught by the outerdetect_performance_problemsexception handler and logged as "Failed to detect performance problems", meaning N+1 detection silently fails for these segments.Fix: Use
db_span.get("description", "")— consistent with howtransaction_nameis accessed via.get()two lines below in the same function.Files changed:
src/sentry/issue_detection/detectors/mn_plus_one_db_span_detector.pyLegal 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