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): handle missing initial event (#71067)

Hugues Pouillot335a4d6b0a96
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
index 3f9570076cb4..af7ca9d20877 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
@@ -1,3 +1,5 @@
+import { expectLogic } from 'kea-test-utils'
+
import { ErrorTrackingFingerprint } from 'lib/components/Errors/types'
import { useMocks } from '~/mocks/jest'
@@ -55,4 +57,12 @@ describe('errorTrackingIssueSceneLogic', () => {
expect(logic.values.eventsQueryKey).not.toBe(initialKey)
})
+
+ it('handles an empty initial event query result', async () => {
+ await expectLogic(logic, () => {
+ logic.actions.loadInitialEvent('2026-01-01T00:00:00Z')
+ })
+ .toDispatchActions(['loadInitialEventSuccess'])
+ .toMatchValues({ initialEvent: null })
+ })
})
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
index ca96b2b3274c..0ffda6a48020 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
@@ -221,11 +221,8 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType
}),
{ refresh: 'blocking' }
)
- const issue = response.results[0]
- let positionEvent = null
- if (issue.last_event) {
- positionEvent = issue.last_event
- } else {
+ const positionEvent = response.results[0]?.last_event
+ if (!positionEvent) {
return null
}
const initialEvent: ErrorEventType = {