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): match fingerprint route with a wildcard (#74823)

Aleksander Błaszkiewiczce192d61417c
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index 4a54d87e9036..a42023fc1897 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -150,7 +150,7 @@ export const productRoutes: Record<string, [string, string]> = {
],
'/engineering-analytics/authors/:handle': ['EngineeringAnalyticsAuthor', 'engineeringAnalyticsAuthor'],
'/error_tracking': ['ErrorTracking', 'errorTracking'],
- '/error_tracking/fingerprint/:fingerprint': ['ErrorTrackingFingerprint', 'errorTrackingFingerprint'],
+ '/error_tracking/fingerprint/*': ['ErrorTrackingFingerprint', 'errorTrackingFingerprint'],
'/error_tracking/:id': ['ErrorTrackingIssue', 'errorTrackingIssue'],
'/error_tracking/:id/fingerprints': ['ErrorTrackingIssueFingerprints', 'errorTrackingIssueFingerprints'],
'/error_tracking/alerts/:id': ['HogFunction', 'errorTrackingAlert'],
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/ErrorTrackingFingerprintScene.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/ErrorTrackingFingerprintScene.tsx
index a9e21528e212..e141dd91cc2b 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/ErrorTrackingFingerprintScene.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/ErrorTrackingFingerprintScene.tsx
@@ -15,12 +15,11 @@ import {
export const scene: SceneExport<ErrorTrackingFingerprintSceneLogicProps> = {
component: ErrorTrackingFingerprintScene,
logic: errorTrackingFingerprintSceneLogic,
- paramsToProps: ({ params: { fingerprint }, searchParams: { timestamp } }) => ({
- // Decode from the raw pathname, not the router's already-decodeURI'd `fingerprint` param —
- // decoding that a second time crashes on a literal `%` and mangles `%XX` fingerprints.
- fingerprint: decodeFingerprintSegment(
- rawFingerprintPathSegment(router.values.location.pathname) ?? fingerprint
- ),
+ // `_` is the wildcard capture from the `/error_tracking/fingerprint/*` route.
+ paramsToProps: ({ params: { _: wildcard }, searchParams: { timestamp } }) => ({
+ // Decode from the raw pathname, not the router's already-decodeURI'd capture — decoding that
+ // a second time crashes on a literal `%` and mangles `%XX` fingerprints.
+ fingerprint: decodeFingerprintSegment(rawFingerprintPathSegment(router.values.location.pathname) ?? wildcard),
timestamp,
}),
}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/errorTrackingFingerprintRoute.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/errorTrackingFingerprintRoute.test.ts
new file mode 100644
index 000000000000..337e418428c1
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingFingerprintScene/errorTrackingFingerprintRoute.test.ts
@@ -0,0 +1,47 @@
+import { kea, path } from 'kea'
+import { router, urlToAction } from 'kea-router'
+
+import { productRoutes } from '~/products'
+import { initKeaTests } from '~/test/init'
+
+const fingerprintRoute = Object.entries(productRoutes).find(
+ ([, [scene]]) => scene === 'ErrorTrackingFingerprint'
+)?.[0] as string
+
+describe('error tracking fingerprint route', () => {
+ // A fingerprint is arbitrary exception text, and kea-router matches routes against
+ // `decodeURI(pathname)` — which unescapes `%5B` to `[`, `%20` to a space, and every non-ASCII
+ // escape to its character. Those fall outside the router's global `segmentValueCharset`, so
+ // while this route used a named `:fingerprint` segment an alert link such as
+ // /error_tracking/fingerprint/Error%3A%20%5BcashFlowDrilldown%5D matched no route at all and the
+ // app rendered its 404 scene instead of resolving the fingerprint. A wildcard skips the charset.
+ let matched = false
+
+ const routeLogic = kea([
+ path(['products', 'error_tracking', 'scenes', 'errorTrackingFingerprintRouteTest']),
+ urlToAction(() => ({
+ [fingerprintRoute]: () => {
+ matched = true
+ },
+ })),
+ ])
+
+ beforeEach(() => {
+ matched = false
+ initKeaTests(false)
+ routeLogic.mount()
+ })
+
+ afterEach(() => routeLogic.unmount())
+
+ it.each([
+ ['Error: [cashFlowDrilldown] FDQL row validation failed'],
+ ['Błąd podczas ładowania 中文 🙂'],
+ ['TypeError: {"a":1} <html> `tpl` (500)'],
+ ['fp-1'],
+ ])('routes an alert link for the fingerprint %s', (fingerprint) => {
+ router.actions.push(`/error_tracking/fingerprint/${encodeURIComponent(fingerprint)}`)
+
+ expect(matched).toBe(true)
+ })
+})
diff --git a/products/error_tracking/manifest.tsx b/products/error_tracking/manifest.tsx
index 3bc30105a5d1..f3e346eb9922 100644
--- a/products/error_tracking/manifest.tsx
+++ b/products/error_tracking/manifest.tsx
@@ -36,7 +36,7 @@ export const manifest: ProductManifest = {
},
routes: {
'/error_tracking': ['ErrorTracking', 'errorTracking'],
- '/error_tracking/fingerprint/:fingerprint': ['ErrorTrackingFingerprint', 'errorTrackingFingerprint'],
+ '/error_tracking/fingerprint/*': ['ErrorTrackingFingerprint', 'errorTrackingFingerprint'],
'/error_tracking/:id': ['ErrorTrackingIssue', 'errorTrackingIssue'],
'/error_tracking/:id/fingerprints': ['ErrorTrackingIssueFingerprints', 'errorTrackingIssueFingerprints'],
'/error_tracking/alerts/:id': ['HogFunction', 'errorTrackingAlert'],