Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(error-tracking): guard against malformed timestamp param on issue scene (#70933)

posthog[bot]a2e125eeded8
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
index af7ca9d20877..5463bd601e34 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
@@ -65,4 +65,19 @@ describe('errorTrackingIssueSceneLogic', () => {
.toDispatchActions(['loadInitialEventSuccess'])
.toMatchValues({ initialEvent: null })
})
+
+ // A malformed `timestamp` URL param used to be stored and fed to getNarrowDateRange, where
+ // dayjs().toISOString() threw a RangeError and crashed the whole scene on mount. It must now
+ // be ignored so the scene falls back to the valid server-provided timestamp.
+ it.each(['not-a-date', 'undefined', '2026-01-02T03%3A04%3A05'])(
+ 'ignores a malformed initial event timestamp (%s)',
+ (bad) => {
+ logic.actions.setInitialEventTimestamp(bad)
+ expect(logic.values.initialEventTimestamp).toBeNull()
+
+ // A valid timestamp (as the server's last_seen provides) is still accepted afterwards.
+ logic.actions.setInitialEventTimestamp('2026-01-02T03:04:05Z')
+ expect(logic.values.initialEventTimestamp).toBe('2026-01-02T03:04:05Z')
+ }
+ )
})
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
index 5ea00bc40d57..0306788e5dde 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
@@ -636,8 +636,12 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType
loadSimilarIssuesFailure: (_, { error }) => error,
},
initialEventTimestamp: {
+ // A malformed `timestamp` URL param (truncated/mangled shared links, crawlers) would
+ // otherwise be stored and fed to getNarrowDateRange, where dayjs().toISOString() throws
+ // a RangeError on an Invalid Date. Ignore invalid values so we fall back to the valid
+ // last_seen/first_seen the server provides, exactly as if no timestamp were passed.
setInitialEventTimestamp: (state, { timestamp }) => {
- if (!state && timestamp) {
+ if (!state && timestamp && dayjs(timestamp).isValid()) {
return timestamp
}
return state
@@ -702,6 +706,11 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType
},
initialEvent: {
loadInitialEvent: async ({ timestamp }) => {
+ // Guard the narrow-range formatting below: an invalid timestamp makes
+ // getNarrowDateRange throw a RangeError. Treat it as "no initial event".
+ if (!dayjs(timestamp).isValid()) {
+ return null
+ }
const response = await api.query(
errorTrackingIssueQuery({
issueId: props.id,