Skip to content

fix(insights): validate each value of a multi-value regex filter - #4

Draft
evanmarshall wants to merge 1 commit into
masterfrom
ito/upstream-pr-93586-f7bb6b2f
Draft

fix(insights): validate each value of a multi-value regex filter#4
evanmarshall wants to merge 1 commit into
masterfrom
ito/upstream-pr-93586-f7bb6b2f

Conversation

@evanmarshall

@evanmarshall evanmarshall commented Sep 2, 2026

Copy link
Copy Markdown

This is an Ito QA mirror of PostHog#93586.

Original author: @ksvat
Pinned upstream head: f7bb6b2

This draft is for QA and build-environment experimentation and will not be merged.


Problem

Editing a regex property filter that holds several values showed a yellow validation error reading `this.str.codePointAt is not a function`.

A `visited_page` filter ORs its regex values, so its `value` is an array. The regex validator called `RE2JS.compile(value)`, which expects a single string. Given an array, RE2JS builds a string iterator over it and `array.codePointAt` does not exist, so it threw, and the raw internal error was shown to the user.

This surfaced when editing an AI-drafted Replay Vision scanner (the drafter emits multi-value `regex` `visited_page` filters), but it affects any multi-value regex filter in the app. Pre-existing on master; not introduced by the drafter.

Changes

  • `getRegexValidationError` now normalizes the value to a list and compiles each pattern, returning the first that fails. A valid multi-value regex filter validates cleanly; an invalid one reports a real regex error instead of the internal `codePointAt` message.
  • Exported `getValidationError` so the pure validation logic has a unit test.

How did you test this code?

  • OperatorValueSelect.test.tsx (new): a valid multi-value regex array validates without error; an array with one bad pattern reports a real error and never the `codePointAt` message; a single invalid regex still errors (no regression). 3 tests pass.
  • TypeScript check and lint pass on the changed files.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Found by editing an AI-drafted scanner's page filters. Written with Claude Code. No customer conversation, ticket, or log shaped this change.


Created with PostHog Desktop

Editing a regex property filter that holds several values (a visited_page
filter ORs its regexes, so its value is an array) showed the error
"this.str.codePointAt is not a function". RE2JS.compile expects a single
string and was handed the whole array, so its internal string iterator threw.

The validation now compiles each value and surfaces the first that fails, so
a valid multi-value regex filter validates cleanly and an invalid one reports
a real regex error.

Generated-By: PostHog Desktop
Task-Id: 95802e00-ecde-46c6-b1a1-2f8e96a60183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants