From e630c5fe29411a651f04003b8ec9cafd07145195 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Thu, 6 Aug 2026 22:44:48 +0000 Subject: [PATCH 1/3] fix(page-filters): Handle invalid stats period gracefully --- static/app/components/pageFilters/actions.tsx | 11 ++++++++++- static/app/components/timeRangeSelector/utils.tsx | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/static/app/components/pageFilters/actions.tsx b/static/app/components/pageFilters/actions.tsx index 23b969fc75a1..17ac0728ba1e 100644 --- a/static/app/components/pageFilters/actions.tsx +++ b/static/app/components/pageFilters/actions.tsx @@ -19,7 +19,10 @@ import { setPageFiltersStorage, } from 'sentry/components/pageFilters/persistence'; import {PageFiltersStore} from 'sentry/components/pageFilters/store'; -import {parseStatsPeriod} from 'sentry/components/timeRangeSelector/utils'; +import { + parseStatsPeriod, + STATS_PERIOD_REGEX, +} from 'sentry/components/timeRangeSelector/utils'; import {OrganizationStore} from 'sentry/stores/organizationStore'; import type {DateString, PageFilters, PinnedPageFilter} from 'sentry/types/core'; import type {Organization} from 'sentry/types/organization'; @@ -318,6 +321,12 @@ export function initializeUrlState({ if (maxPickableDays && pageFilters.datetime) { let {start, end} = pageFilters.datetime; + if (pageFilters.datetime.period && !STATS_PERIOD_REGEX.test(pageFilters.datetime.period)) { + // Invalid period from localStorage or URL — fall back to the default period + // rather than letting parseStatsPeriod throw and crash the page. + pageFilters.datetime.period = defaultDatetime.period; + } + if (pageFilters.datetime.period) { const parsedPeriod = parseStatsPeriod(pageFilters.datetime.period); start = parsedPeriod.start; diff --git a/static/app/components/timeRangeSelector/utils.tsx b/static/app/components/timeRangeSelector/utils.tsx index a6e1d5250806..5f00f6d80a7d 100644 --- a/static/app/components/timeRangeSelector/utils.tsx +++ b/static/app/components/timeRangeSelector/utils.tsx @@ -29,7 +29,7 @@ type RelativeUnitsMapping = Record< const DATE_TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ss'; -const STATS_PERIOD_REGEX = /^(\d+)([mhdw])$/; +export const STATS_PERIOD_REGEX = /^(\d+)([mhdw])$/; const SUPPORTED_RELATIVE_PERIOD_UNITS: RelativeUnitsMapping = { m: { From 49ba6d00c0b566747f08f1d26bf91225456d1077 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 00:08:39 +0000 Subject: [PATCH 2/3] fix(pageFilters): Handle invalid stats period gracefully --- static/app/components/pageFilters/actions.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/static/app/components/pageFilters/actions.tsx b/static/app/components/pageFilters/actions.tsx index 17ac0728ba1e..01428e10dd8d 100644 --- a/static/app/components/pageFilters/actions.tsx +++ b/static/app/components/pageFilters/actions.tsx @@ -19,10 +19,7 @@ import { setPageFiltersStorage, } from 'sentry/components/pageFilters/persistence'; import {PageFiltersStore} from 'sentry/components/pageFilters/store'; -import { - parseStatsPeriod, - STATS_PERIOD_REGEX, -} from 'sentry/components/timeRangeSelector/utils'; +import {parseStatsPeriod, STATS_PERIOD_REGEX} from 'sentry/components/timeRangeSelector/utils'; import {OrganizationStore} from 'sentry/stores/organizationStore'; import type {DateString, PageFilters, PinnedPageFilter} from 'sentry/types/core'; import type {Organization} from 'sentry/types/organization'; From 11ffb483e440ce12af04f713a1d4fe219a45297b Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 00:10:09 +0000 Subject: [PATCH 3/3] :hammer_and_wrench: apply pre-commit fixes --- static/app/components/pageFilters/actions.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/static/app/components/pageFilters/actions.tsx b/static/app/components/pageFilters/actions.tsx index 01428e10dd8d..314b182d1e13 100644 --- a/static/app/components/pageFilters/actions.tsx +++ b/static/app/components/pageFilters/actions.tsx @@ -19,7 +19,10 @@ import { setPageFiltersStorage, } from 'sentry/components/pageFilters/persistence'; import {PageFiltersStore} from 'sentry/components/pageFilters/store'; -import {parseStatsPeriod, STATS_PERIOD_REGEX} from 'sentry/components/timeRangeSelector/utils'; +import { + parseStatsPeriod, + STATS_PERIOD_REGEX, +} from 'sentry/components/timeRangeSelector/utils'; import {OrganizationStore} from 'sentry/stores/organizationStore'; import type {DateString, PageFilters, PinnedPageFilter} from 'sentry/types/core'; import type {Organization} from 'sentry/types/organization'; @@ -318,7 +321,10 @@ export function initializeUrlState({ if (maxPickableDays && pageFilters.datetime) { let {start, end} = pageFilters.datetime; - if (pageFilters.datetime.period && !STATS_PERIOD_REGEX.test(pageFilters.datetime.period)) { + if ( + pageFilters.datetime.period && + !STATS_PERIOD_REGEX.test(pageFilters.datetime.period) + ) { // Invalid period from localStorage or URL — fall back to the default period // rather than letting parseStatsPeriod throw and crash the page. pageFilters.datetime.period = defaultDatetime.period;