Skip to content

fix: guard against None target_type in WorkflowEngineActionSerializer and missing description in MNPlusOne detector#119451

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

fix: guard against None target_type in WorkflowEngineActionSerializer and missing description in MNPlusOne detector#119451
billyvg wants to merge 1 commit into
masterfrom
claude/serene-cannon-toun4n

Conversation

@billyvg

@billyvg billyvg commented Jul 11, 2026

Copy link
Copy Markdown
Member

Fixes two production errors surfaced by automated Sentry alert monitoring.

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


Fix 1: SENTRY-5NQGValueError: None is not a valid ActionTarget (medium severity)

Issue: SENTRY-5NQG — 6,500+ events, ongoing since Apr 22

Root cause: WorkflowEngineActionSerializer calls ActionTarget(target_type) where target_type is None for webhook-type actions (they have no target). The enum constructor raises ValueError: None is not a valid ActionTarget, which propagates through SentryAppMetricAlertHandler → invoke_legacy_registry → get_incident_serializer, causing metric alert webhook notifications to silently fail to serialize.

Fix: Guard the ActionTarget() call with a None check, returning None for targetType when no target type is configured — consistent with how desc is already handled on the line below it.

Files changed:

  • src/sentry/incidents/endpoints/serializers/workflow_engine_action.py

Fix 2: SENTRY-5QVDKeyError: 'description' in MNPlusOne DB span detector (medium severity)

Issue: SENTRY-5QVD — 213k+ events, ongoing since Jun 25

Root cause: ContinuingMNPlusOne._maybe_performance_problem() accesses db_span["description"] directly. New span schema (spans emitting downsampled_retention_days rather than the standard span fields) causes some spans to arrive without a description key. The KeyError is caught by the outer detect_performance_problems exception 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 how transaction_name is accessed via .get() two lines below in the same function.

Files changed:

  • src/sentry/issue_detection/detectors/mn_plus_one_db_span_detector.py

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

…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
@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