fix(insights): Handle null span.group in Backend Insights widgets#112379
fix(insights): Handle null span.group in Backend Insights widgets#112379
Conversation
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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.
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; |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit e37778b. Configure here.



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.,
span.groupattribute, but decisions around OTel are changing! We might do less enrichment (or different enrichment) thereIn the meantime, this PR makes two changes
has:span.groupto be present in a few widgets. This is a common pattern for us, and should work here, toospan.groupproperty to mark it as possiblynulland updates a bunch of usageFixes DAIN-1467