Skip to content

Accept portable case classes in regex filters - #9515

Open
DsThakurRawat wants to merge 2 commits into
jaegertracing:mainfrom
DsThakurRawat:fix/9483-portable-case-classes
Open

Accept portable case classes in regex filters#9515
DsThakurRawat wants to merge 2 commits into
jaegertracing:mainfrom
DsThakurRawat:fix/9483-portable-case-classes

Conversation

@DsThakurRawat

Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

Description of the changes

  • checkPortable decided this from re.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 to validatePattern as a lexical scan, hasInlineCaseFolding, and the AST check is removed.
  • The scan knows about the three things that make a naive scan wrong: \Q...\E quoting, 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.
  • The refusal message becomes "a pattern cannot use an inline case-folding flag", which is what is actually being refused. The one existing assertion on the old wording is updated; (?i)get is still refused.
  • Behind 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_Accepts gains [gG]et, (g|G)et, \Q(?i)\Eget and (?-i)get; TestValidateFilter_Rejects gains (?i:get), g(?i)et and (?is)get next to the existing (?i)get.
  • TestHasInlineCaseFolding covers 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 and golangci-lint reports nothing on the package. A full make lint-go on this machine reports one pre-existing nolintlint finding in jaegerquery/internal/server.go, which this PR does not touch.

Checklist

AI Usage in this PR (choose one)

See AI Usage Policy.

  • Moderate: AI helped with code generation or debugging specific parts

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>
@DsThakurRawat
DsThakurRawat requested a review from a team as a code owner September 8, 2026 09:41
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.56%. Comparing base (0413ecd) to head (5ef37c3).

Files with missing lines Patch % Lines
...ernal/storage/v2/api/tracestore/filter_validate.go 97.29% 1 Missing ⚠️
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     
Flag Coverage Δ
badger_direct 7.41% <0.00%> (-0.03%) ⬇️
badger_e2e 12.15% <0.00%> (-0.03%) ⬇️
cassandra-4.x-direct-manual 12.06% <0.00%> (-0.05%) ⬇️
cassandra-4.x-e2e-auto 18.48% <0.00%> (-0.04%) ⬇️
cassandra-4.x-e2e-manual 18.48% <0.00%> (-0.04%) ⬇️
cassandra-5.x-direct-manual 12.06% <0.00%> (-0.05%) ⬇️
cassandra-5.x-e2e-auto 18.48% <0.00%> (-0.04%) ⬇️
cassandra-5.x-e2e-manual 18.48% <0.00%> (-0.04%) ⬇️
clickhouse-direct 7.94% <0.00%> (-0.03%) ⬇️
clickhouse-e2e 14.01% <0.00%> (-0.04%) ⬇️
elasticsearch-7.x-direct 24.70% <0.00%> (-0.09%) ⬇️
elasticsearch-8.x-direct 24.73% <0.00%> (-0.09%) ⬇️
elasticsearch-8.x-e2e 23.41% <16.21%> (-0.02%) ⬇️
elasticsearch-9.x-direct 24.73% <0.00%> (-0.09%) ⬇️
elasticsearch-9.x-e2e 23.41% <16.21%> (-0.02%) ⬇️
grpc_direct 7.10% <0.00%> (-0.03%) ⬇️
grpc_e2e 13.31% <0.00%> (-0.03%) ⬇️
kafka-3.x-v2 24.17% <16.21%> (-0.03%) ⬇️
memory_v2 16.63% <0.00%> (-0.04%) ⬇️
opensearch-1.x-direct 24.70% <0.00%> (-0.09%) ⬇️
opensearch-2.x-direct 24.70% <0.00%> (-0.09%) ⬇️
opensearch-2.x-e2e 23.40% <16.21%> (-0.02%) ⬇️
opensearch-3.x-direct 24.70% <0.00%> (-0.09%) ⬇️
opensearch-3.x-e2e 23.40% <16.21%> (-0.02%) ⬇️
query 13.26% <0.00%> (-0.03%) ⬇️
tailsampling-processor 7.03% <0.00%> (-0.02%) ⬇️
unittests 97.44% <97.29%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

CI Summary Report

Metrics Comparison

⚠️ 4 metric change(s) detected (informational)

View changed metrics

For label-level diff details, open the CI run and expand the "Compare metrics and generate summary" step logs.

metrics_snapshot_kafka_v2⬇️ download diff
4 modified

  • otelcol_kafka_exporter_bytes
  • otelcol_kafka_exporter_bytes_uncompressed
  • otelcol_kafka_exporter_messages
  • otelcol_kafka_exporter_records

Code Coverage

✅ Coverage 98.7% (baseline 98.7%)

➡️ View CI run | View publish logs
2026-09-08 10:04:50 UTC

@vjkumar2756 vjkumar2756 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured filter refuses portable case classes, which RFC 0005 §5.3 does not

2 participants