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(replay-vision): stop scanner page crash on malformed id (#118221)

posthog[bot]1d25f4a6ee48
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
index b79bdf2568df..806219971d46 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
@@ -1574,6 +1574,12 @@ describe('replayScannerLogic', () => {
})
})
+ it('mounts when the scanner id carries a url-pattern token', () => {
+ const malformedLogic = replayScannerLogic({ id: 'abc)' })
+ expect(() => malformedLogic.mount()).not.toThrow()
+ malformedLogic.unmount()
+ })
+
describe('observationsPage / sort URL sync', () => {
let scannedLogic: ReturnType<typeof replayScannerLogic.build>
let observationRequests: URL[]
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index 6597fa6ae808..e7b0c01da311 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -2840,7 +2840,11 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
urlToAction(({ actions, values, props }) => ({
// Restore as one atomic action (individual setters would reset the page); dispatch only on actual change.
- [urls.replayVision(props.id)]: (_, searchParams) => {
+ // A static pattern: url-pattern throws on an id with pattern tokens, e.g. a `)` copied from a Markdown link.
+ [urls.replayVision(':id')]: ({ id }, searchParams) => {
+ if (id !== props.id) {
+ return
+ }
const pageRaw = Number(searchParams.page ?? 1)
const page = Number.isFinite(pageRaw) ? Math.max(1, pageRaw) : 1
const sort = parseSortParam(searchParams.sort) ?? DEFAULT_OBSERVATIONS_SORT