Skip to content

fix: LineFilterLabelFilter.String() regexp correct delimiters (backport release-3.6.x) - #20649

Merged
trevorwhitney merged 1 commit into
release-3.6.xfrom
backport-17129-to-release-3.6.x
Feb 2, 2026
Merged

fix: LineFilterLabelFilter.String() regexp correct delimiters (backport release-3.6.x)#20649
trevorwhitney merged 1 commit into
release-3.6.xfrom
backport-17129-to-release-3.6.x

Conversation

@loki-gh-app

@loki-gh-app loki-gh-app Bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Backport 0303aee from #17129


What this PR does / why we need it:
When the querysharder executes, it converts a query into an AST representation before forwarding it on to the queriers. Unfortunately, when this AST representation is converted back into a string, it does not handle the case where a regexp can contain backticks - it always tries to wrap the regexp in backticks, which can lead to parser errors. This PR updates the String() method that converted the filter back into a query string and adapts the delimiters based on the content of the regexp.

Which issue(s) this PR fixes:
Fixes #16674

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR
When the querysharder executes, it converts a query into an AST representation before forwarding it on to the queriers. Unfortunately, when this AST representation is converted back into a string, it does not handle the case where a regexp can contain backticks - it always tries to wrap the regexp in backticks, which can lead to parser errors. This PR updates the String() method that converted the filter back into a query string and adapts the delimiters based on the content of the regexp.

(cherry picked from commit 0303aee)
@loki-gh-app
loki-gh-app Bot requested a review from a team as a code owner February 2, 2026 16:42
@loki-gh-app loki-gh-app Bot added backport size/M type/bug Somehing is not working as expected labels Feb 2, 2026
@loki-gh-app
loki-gh-app Bot requested a review from chaudum February 2, 2026 16:42
@trevorwhitney
trevorwhitney enabled auto-merge (squash) February 2, 2026 16:43
@trevorwhitney
trevorwhitney merged commit 9d5fb5f into release-3.6.x Feb 2, 2026
71 checks passed
@trevorwhitney
trevorwhitney deleted the backport-17129-to-release-3.6.x branch February 2, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport size/M type/bug Somehing is not working as expected

2 participants