Skip to content

Commit 27e7094

Browse files
fix(spike protection): Handle null threshold (#103450)
`initialThreshold` on a spike can be null (eventually gets filled); this PR handles that case so we don't error out the whole spike table.
1 parent da9f6aa commit 27e7094

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

static/gsApp/views/spikeProtection/spikeProtectionHistoryTable.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {space} from 'sentry/styles/space';
1818
import type {DataCategoryInfo} from 'sentry/types/core';
1919
import type {Organization} from 'sentry/types/organization';
2020
import type {Project} from 'sentry/types/project';
21+
import {defined} from 'sentry/utils';
2122
import {getExactDuration} from 'sentry/utils/duration/getExactDuration';
2223
import {decodeScalar} from 'sentry/utils/queryString';
2324
import useApi from 'sentry/utils/useApi';
@@ -130,11 +131,13 @@ class SpikeProtectionHistoryTable extends Component<Props> {
130131
return [
131132
<SpikeProtectionTimeDetails spike={spike} key="time" />,
132133
<StyledCell key="threshold">
133-
{formatUsageWithUnits(
134-
spike.threshold,
135-
dataCategoryInfo.plural,
136-
getFormatUsageOptions(dataCategoryInfo.plural)
137-
)}
134+
{defined(spike.threshold)
135+
? formatUsageWithUnits(
136+
spike.threshold,
137+
dataCategoryInfo.plural,
138+
getFormatUsageOptions(dataCategoryInfo.plural)
139+
)
140+
: '-'}
138141
</StyledCell>,
139142
<StyledCell key="duration">
140143
{duration ? getExactDuration(duration, true) : t('Ongoing')}

static/gsApp/views/spikeProtection/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {DataCategoryInfo} from 'sentry/types/core';
33
export interface SpikeDetails {
44
dataCategory: DataCategoryInfo['name'];
55
start: string;
6-
threshold: number;
6+
threshold: number | null;
77
dropped?: number;
88
duration?: number | null;
99
end?: string;

0 commit comments

Comments
 (0)