model/labels: fix regex with capture, wildcards, literal #17828
model/labels: fix regex with capture, wildcards, literal #17828bboreham merged 2 commits intoprometheus:mainfrom
Conversation
|
Fuzz testing output from https://github.com/grafana/mimir-prometheus/actions/runs/20844945972/job/59886370766?pr=1057 |
This change fixes an issue introduced in prometheus#17707. When a regex with a wildcard, literal, and final wildcard surounded by a capture group was parsed - the capture group was not removed first preventing `optimizeConcatRegex` from running. Found via fuzz testing. Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
80b20f3 to
9e6338c
Compare
|
This looks reasonable to me. Cursor suggests to do this before the |
charleskorn
left a comment
There was a problem hiding this comment.
LGTM, thanks for catching this and fixing it!
There was a problem hiding this comment.
I'm ok to accept this, but I can't see how #17707 would cause it.
The previous code calls clearCapture on sub-expressions not on the top level.
Update: ok I see it now. If there is a capture then the intended optimisation doesn't work.
|
I'm going to squash this as the change is not huge and the commit message on the first commit seems inaccurate. |
This change fixes an issue introduced in #17707. When a regex with a wildcard, literal, and final wildcard surounded by a capture group was parsed - the capture group was not removed first preventing
optimizeConcatRegexfrom running.Found via fuzz testing.
Which issue(s) does the PR fix:
Related #17707
Note to reviewers
The first commit contains a regex that will trigger the issue causing many tests to fail. The second commit contains the fix.
Does this PR introduce a user-facing change?