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(surveys): coerce numeric search query param to string (#66883)

Phillb34794c075c2
diff --git a/frontend/src/scenes/surveys/surveysLogic.test.ts b/frontend/src/scenes/surveys/surveysLogic.test.ts
index 44c93e9efb44..a83a68d633ba 100644
--- a/frontend/src/scenes/surveys/surveysLogic.test.ts
+++ b/frontend/src/scenes/surveys/surveysLogic.test.ts
@@ -179,6 +179,16 @@ describe('surveysLogic', () => {
})
})
+ it('coerces a numeric search query param to a string without crashing searchedSurveys', async () => {
+ router.actions.push('/surveys', { search: 3 })
+
+ await expectLogic(logic).toFinishAllListeners().toMatchValues({
+ searchTerm: '3',
+ })
+
+ expect(logic.values.searchedSurveys).toEqual([])
+ })
+
it('clears a stale search term when navigating to surveys without a search param', async () => {
await expectLogic(logic, () => {
logic.actions.setSearchTerm('onboarding')
diff --git a/frontend/src/scenes/surveys/surveysLogic.tsx b/frontend/src/scenes/surveys/surveysLogic.tsx
index 2a0c9adf6edb..5c28e1fe44f5 100644
--- a/frontend/src/scenes/surveys/surveysLogic.tsx
+++ b/frontend/src/scenes/surveys/surveysLogic.tsx
@@ -494,7 +494,8 @@ export const surveysLogic = kea<surveysLogicType>([
if (tab) {
actions.setTab(tab)
}
- const nextSearchTerm = search ?? ''
+ // The router parses purely-numeric query params into numbers, so coerce to a string.
+ const nextSearchTerm = search != null ? String(search) : ''
if (nextSearchTerm !== values.searchTerm) {
actions.setSearchTerm(nextSearchTerm)
}