RE2-unsafe regex patterns: audit production segments and decide fallback policy
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Domain
- backend-api-design, databases
Research direction
Start with _RE2_UNSAFE in src/flagsmith_sql_flag_engine/translator.py and inspect the engine-test-data suite. Run the proposed REGEXP_LIKE audit against the segments table’s rules JSON column to measure usage of backreferences and lookarounds. Done means the prevalence is recorded, a fallback policy is chosen, and the corresponding behavior is implemented and validated.
Written by the indexing model from the issue text.
Description
The translator returns None for any REGEX condition whose pattern contains:
- Backreferences (
\1–\9) - Lookarounds (
(?=,(?!,(?<=,(?<!)
Snowflake uses RE2, which doesn't support either feature. The detection is conservative-syntactic in _RE2_UNSAFE (src/flagsmith_sql_flag_engine/translator.py).
The engine-test-data suite doesn't include any RE2-unsafe patterns, currently.
What to do
- Audit production segment definitions for either pattern —
REGEXP_LIKEover the segments table'srulesJSON column with a pattern that catches\1–\9or(?=/(?!/(?<=/(?<!as substrings. Cheap query, gives a real prevalence number. - Decide fallback policy based on prevalence:
- If essentially nobody uses these features (most likely): surface the error at segment-edit time. The Flagsmith UI rejects the pattern with a clear "Snowflake-backed envs do not support backreferences / lookarounds" message. Translator's
Nonereturn becomes an unreachable defensive branch. - If non-trivial usage: ship a fallback that runs the pattern through the Python flag_engine just for those segments, e.g. by calling out to an
is_in_segmentUDF. Adds back the per-row Python tax but only for the affected segments.
- If essentially nobody uses these features (most likely): surface the error at segment-edit time. The Flagsmith UI rejects the pattern with a clear "Snowflake-backed envs do not support backreferences / lookarounds" message. Translator's
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-sql-flag-engine
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Dependency Dashboard Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in Flagsmith/flagsmith-sql-flag-engine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100