fix(insights): validate each value of a multi-value regex filter - #4
Draft
evanmarshall wants to merge 1 commit into
Draft
fix(insights): validate each value of a multi-value regex filter#4evanmarshall wants to merge 1 commit into
evanmarshall wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.🤖 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