Skip to content

fix(insights): Handle null span.group in Backend Insights widgets#112379

Open
gggritso wants to merge 2 commits intomasterfrom
georgegritsouk/dain-1467-backend-insights-crashes-and-does-not-render-fully-on
Open

fix(insights): Handle null span.group in Backend Insights widgets#112379
gggritso wants to merge 2 commits intomasterfrom
georgegritsouk/dain-1467-backend-insights-crashes-and-does-not-render-fully-on

Conversation

@gggritso
Copy link
Copy Markdown
Member

@gggritso gggritso commented Apr 7, 2026

A self-hosted user complained in getsentry/self-hosted#4262 that their Backend Insights view breaks when ingesting Otel data. This PR adds some guards to prevent this crash, but it doesn't necessarily guarantee a great experience, e.g.,

  • "Backend Insights" is on its way out, to be replaced with a pre-built dashboard. This hasn't been rolled out to self-hosted yet, so this user will have a somewhat different experience in the next few months if they upgrade
  • OTel data should go through Sentry enrichment, and get a span.group attribute, but decisions around OTel are changing! We might do less enrichment (or different enrichment) there

In the meantime, this PR makes two changes

  • asks for has:span.group to be present in a few widgets. This is a common pattern for us, and should work here, too
  • updates the types for the span.group property to mark it as possibly null and updates a bunch of usage

Fixes DAIN-1467

gggritso added 2 commits April 7, 2026 13:09
Widgets that query for span.group can receive null values from the
backend for OpenTelemetry-ingested spans, causing the page to crash.
Add has:span.group to the search queries in overviewTimeConsumingQueriesWidget
and overviewSlowNextjsSSRWidget, matching the pattern already used by
overviewSlowAssetsWidget and overviewSlowQueriesChartWidget.

Fixes DAIN-1467
Move SPAN_GROUP from NonNullableStringFields to NullableStringFields,
reflecting the reality that OpenTelemetry-ingested spans can have null
span.group values. This makes SpanResponse['span.group'] resolve to
string | null, letting TypeScript catch unsafe usages.

Fix all surfaced type errors by updating prop types to accept null and
adding null coalescing where values are passed to MutableSearch.
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 7, 2026
@gggritso gggritso marked this pull request as ready for review April 7, 2026 19:24
@gggritso gggritso requested review from a team as code owners April 7, 2026 19:25
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Null group interpolated into navigation URL path
    • Added a guard in QueryClippedBox so the click handler returns early when group is null/undefined instead of navigating to a malformed span URL.

Create PR

Or push these changes by commenting:

@cursor push 00baa7392a
Preview (00baa7392a)
diff --git a/static/app/views/insights/common/components/fullSpanDescription.tsx b/static/app/views/insights/common/components/fullSpanDescription.tsx
--- a/static/app/views/insights/common/components/fullSpanDescription.tsx
+++ b/static/app/views/insights/common/components/fullSpanDescription.tsx
@@ -121,11 +121,16 @@
       clipHeight={500}
       buttonProps={{
         icon: <IconOpen />,
-        onClick: () =>
+        onClick: () => {
+          if (!group) {
+            return;
+          }
+
           navigate({
             pathname: `${databaseURL}/spans/span/${group}`,
             query: {...location.query, isExpanded: true},
-          }),
+          });
+        },
       }}
     >
       {children}

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e37778b. Configure here.

type TruncatedQueryClipBoxProps = {
children: ReactNode;
group: string | undefined;
group: string | null | undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null group interpolated into navigation URL path

Medium Severity

The QueryClippedBox component's "View full query" button constructs a navigation URL using the group prop. Since group can now be null, the URL interpolation doesn't guard against it, leading to invalid routes like /spans/span/null. Unlike SpanGroupDetailsLink, it lacks a null guard.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e37778b. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant