Skip to content

Commit 7860532

Browse files
scttcperclaude
andauthored
fix(supergroup): Guard against NaN in supergroup row stats during loading (#112294)
Stats are fetched separately from groups, so when groups are in the store but stats haven't populated yet, `count`/`userCount` are undefined. `parseInt(undefined)` returns `NaN` which propagates through the sum and renders as "NaN" in the supergroup row. Guards with `|| 0` and `?? 0` so partially-loaded groups contribute zero instead of poisoning the total. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d06d2fc commit 7860532

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

static/app/views/issueList/supergroups/aggregateSupergroupStats.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {GroupFixture} from 'sentry-fixture/group';
22

3+
import type {Group} from 'sentry/types/group';
4+
35
import {aggregateSupergroupStats} from './aggregateSupergroupStats';
46

57
describe('aggregateSupergroupStats', () => {
@@ -61,6 +63,15 @@ describe('aggregateSupergroupStats', () => {
6163
expect(result?.mergedFilteredStats).toBeNull();
6264
});
6365

66+
it('treats missing counts as zero when stats have not loaded', () => {
67+
const result = aggregateSupergroupStats(
68+
[GroupFixture({count: '10', userCount: 3}), {} as Group],
69+
'24h'
70+
);
71+
expect(result?.eventCount).toBe(10);
72+
expect(result?.userCount).toBe(3);
73+
});
74+
6475
it('aggregates filtered stats separately', () => {
6576
const groups = [
6677
GroupFixture({

static/app/views/issueList/supergroups/aggregateSupergroupStats.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ export function aggregateSupergroupStats(
5151
let mergedFilteredStats: TimeseriesValue[] | null = null;
5252

5353
for (const group of groups) {
54-
eventCount += parseInt(group.count, 10);
55-
userCount += group.userCount;
54+
eventCount += parseInt(group.count, 10) || 0;
55+
userCount += group.userCount ?? 0;
5656

5757
if (group.filtered) {
5858
filteredEventCount ??= 0;
5959
filteredUserCount ??= 0;
60-
filteredEventCount += parseInt(group.filtered.count, 10);
61-
filteredUserCount += group.filtered.userCount;
60+
filteredEventCount += parseInt(group.filtered.count, 10) || 0;
61+
filteredUserCount += group.filtered.userCount ?? 0;
6262

6363
const filteredStats = group.filtered.stats?.[statsPeriod];
6464
if (filteredStats) {

0 commit comments

Comments
 (0)