Accept portable case classes in regex filters - #9515
Conversation
checkPortable refused [aA]bc, (a|A)bc and [aA][bB] because Go's parser sets FoldCase for a two-element case class exactly as it does for an inline (?i), so the AST cannot tell a portable class from a flag the backends do not share. Decide it lexically in validatePattern instead: an unescaped (?i) or (?i:...) outside a character class is refused, a case class, a quoted \Q(?i)\E, a negated (?-i) and a named group (?P<n>...) are accepted. The message now names what is refused. Signed-off-by: Divyansh Rawat <divyanshrawatofficial@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9515 +/- ##
==========================================
- Coverage 98.56% 98.56% -0.01%
==========================================
Files 392 392
Lines 18382 18417 +35
==========================================
+ Hits 18119 18153 +34
- Misses 263 264 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
CI Summary ReportMetrics ComparisonView changed metricsFor label-level diff details, open the CI run and expand the "Compare metrics and generate summary" step logs. metrics_snapshot_kafka_v2 — ⬇️ download diff
Code Coverage✅ Coverage 98.7% (baseline 98.7%) ➡️ View CI run | View publish logs |
vjkumar2756
left a comment
There was a problem hiding this comment.
@DsThakurRawat
the root cause diagnosis is correct and the
lexical-scan approach is the right solution. A few things to look at before merging:
🔴 Bug: 'I' (uppercase) in groupFoldsCase — untested and likely wrong
In groupFoldsCase:
case 'i', 'I':
if !negated {
return true, j
}
Which problem is this PR solving?
[aA]bc,(a|A)bcand[aA][bB]with "a pattern cannot fold case", although RFC 0005 §5.3 only asks for an inline case-folding flag to be refused, and a case class is ordinary RE2 that every backend handles.Description of the changes
checkPortabledecided this fromre.Flags & syntax.FoldCase, and Go's parser sets that flag for a two-element case class exactly as it does for(?i), so by the time the AST exists the two cannot be told apart. The check moves tovalidatePatternas a lexical scan,hasInlineCaseFolding, and the AST check is removed.\Q...\Equoting, negated flags such as(?-i), and named groups(?P<n>...). A(?i)inside a character class or escaped as\(?i\)is a literal and stays accepted.(?i)getis still refused.jaeger.query.structuredFilters, Alpha and off by default, so nothing changes for a deployment that has not opted in.How was this change tested?
TestValidateFilter_Acceptsgains[gG]et,(g|G)et,\Q(?i)\Egetand(?-i)get;TestValidateFilter_Rejectsgains(?i:get),g(?i)etand(?is)getnext to the existing(?i)get.TestHasInlineCaseFoldingcovers the scanner directly: six folding spellings and fourteen non-folding ones, including quoting, escapes, a class containing(?i), negated and mixed flags, named and non-capturing groups, and truncated input.go test ./internal/storage/v2/...passes andgolangci-lintreports nothing on the package. A fullmake lint-goon this machine reports one pre-existingnolintlintfinding injaegerquery/internal/server.go, which this PR does not touch.Checklist
make lint testAI Usage in this PR (choose one)
See AI Usage Policy.