Skip to content

Conversation

@jjbayer
Copy link
Member

@jjbayer jjbayer commented Nov 24, 2025

Relay already has the ability to configure what part of a pattern match to scrub, but so far it has not been exposed to users. Add a checkbox to the UI to allow scrubbing the first match group instead of the entire expression.

image

Fixes INGEST-625

@linear
Copy link

linear bot commented Nov 24, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 24, 2025
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103885      +/-   ##
===========================================
- Coverage   80.69%    80.58%   -0.12%     
===========================================
  Files        9297      9292       -5     
  Lines      398973    396716    -2257     
  Branches    25286     25284       -2     
===========================================
- Hits       321954    319693    -2261     
- Misses      76559     76563       +4     
  Partials      460       460              

@jjbayer jjbayer changed the title [WIP] Set capture group Allow users to set replaceGroups on regex PII rules Nov 24, 2025
checked={values.replaceCaptured === 'true'}
disabled={!hasCaptureGroups(values.pattern)}
onChange={e =>
onChange('replaceCaptured', e.target.checked.toString())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that replaceCaptured has to be a string, but it is forced by the following type:

export type EditableRule = Omit<Record<KeysOfUnion<Rule>, string>, 'id'>;

@jjbayer jjbayer marked this pull request as ready for review November 24, 2025 15:04
@jjbayer jjbayer requested review from a team and priscilawebdev November 24, 2025 15:04
export function hasCaptureGroups(pattern: string) {
const m = pattern.match(/\(.*\)/);
return m !== null && m.length > 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect regex capture group detection logic

The hasCaptureGroups function incorrectly identifies capture groups by matching any parentheses with /\(.*\)/. This matches non-capturing groups like (?:...), lookaheads like (?=...), and even escaped literal parentheses \(, treating them all as capturing groups when they're not. This causes the checkbox to remain enabled for patterns that don't actually have capture groups.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fair point, but I only use this as a minimal condition to enable the checkbox. The user still needs to willingly check it to enable replacement.

Copy link
Member

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@jjbayer jjbayer merged commit da700e7 into master Nov 26, 2025
48 checks passed
@jjbayer jjbayer deleted the feat/pii-capture-group branch November 26, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants