fix(filtering): reject basic rules with an invalid regex #4882
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 417 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4882"
general
weight: 0.35
ShivamSharma43
Relates to: no issue
This is a bug I found while reading the basic sync rule code.
A basic rule that uses the
regexrule is matched withre.match(self.value, ...)inBasicRule.matches, so its value is only compiled when the sync job runs it against documents. The default basic rule validators (BasicRuleAgainstSchemaValidator,BasicRuleNoMatchAllRegexValidator,BasicRulesSetSemanticValidator) never compile it. So an invalid pattern passes validation and can be activated. A glob-style value such as.pdfis an easy mistake to make here, as is an unclosed[or(.Reproduced on
main, with a ruleexclude/title/regex/.pdf:should_ingestis called for every document inExtractor.get_docswith nothing around it to catch errors. So the first document that has the rule's field fails the whole sync with there.error, instead of the rule being flagged as invalid when it is saved.The fix adds
BasicRuleValidRegexValidator, aBasicRuleValidatorlike the existing ones. Forregexrules it compiles the value and returns an invalid result naming the rule and there.errormessage. Other rule types are not affected (contains/.pdfis still valid). It is added toBaseDataSource.basic_rules_validators(), which no data source overrides, so it applies to every connector. With the fix the same rule is reported as:Checklists
Pre-Review Checklist
config.yml.example)v7.13.2,v7.14.0,v8.0.0)Tests
libs/connectors_sdk/tests/filtering/test_validation.py: newtest_basic_rule_validate_valid_regex.abc,.\.pdf$and acontainsrule with.pdfare valid. The regex values.pdf,report0-9and(draftare invalid, and the message says "invalid regular expression".libs/connectors_sdk/tests/test_source.py:test_base_classnow expects the new validator in the default list.All 306 tests in
libs/connectors_sdk/tests/filteringandlibs/connectors_sdk/tests/test_source.pypass.ruff checkandruff format --checkare clean, apart from the repo-wide CPY001 notice.🤖 Generated with [Claude Code