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(groups): handle malformed percent escapes in group keys (#117586)

Daniel Parkerd03837d75ecc
diff --git a/products/groups/frontend/pages/Group.test.tsx b/products/groups/frontend/pages/Group.test.tsx
new file mode 100644
index 000000000000..3b7ba6b4e585
--- /dev/null
+++ b/products/groups/frontend/pages/Group.test.tsx
@@ -0,0 +1,20 @@
+import { scene } from './Group'
+
+describe('Group scene', () => {
+ it.each<[string, string]>([
+ ['50%25off', '50%off'],
+ ['50%off', '50%off'],
+ ['foo bar', 'foo bar'],
+ ])('paramsToProps turns raw groupKey %s into groupKey %s without throwing', (rawGroupKey, expected) => {
+ expect(
+ scene.paramsToProps?.({
+ params: { groupTypeIndex: '0', groupKey: rawGroupKey },
+ searchParams: {},
+ hashParams: {},
+ })
+ ).toEqual({
+ groupTypeIndex: 0,
+ groupKey: expected,
+ })
+ })
+})
diff --git a/products/groups/frontend/pages/Group.tsx b/products/groups/frontend/pages/Group.tsx
index 67c232500cc5..f17a85cd1c14 100644
--- a/products/groups/frontend/pages/Group.tsx
+++ b/products/groups/frontend/pages/Group.tsx
@@ -14,6 +14,7 @@ import { LemonTabs } from 'lib/lemon-ui/LemonTabs'
import { Link } from 'lib/lemon-ui/Link'
import { Spinner, SpinnerOverlay } from 'lib/lemon-ui/Spinner/Spinner'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { tryDecodeURIComponent } from 'lib/utils/url'
import { NotebookSelectButton } from 'scenes/notebooks/NotebookSelectButton/NotebookSelectButton'
import { NotebookNodeType } from 'scenes/notebooks/types'
import { SceneExport } from 'scenes/sceneTypes'
@@ -54,7 +55,7 @@ export const scene: SceneExport<GroupLogicProps> = {
logic: groupLogic,
paramsToProps: ({ params: { groupTypeIndex, groupKey } }) => ({
groupTypeIndex: parseInt(groupTypeIndex ?? '0'),
- groupKey: decodeURIComponent(groupKey ?? ''),
+ groupKey: tryDecodeURIComponent(groupKey ?? ''),
}),
}