Skip to content

Conversation

@loki-gh-app
Copy link
Contributor

@loki-gh-app loki-gh-app bot commented Oct 21, 2025

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 added backport size/M type/bug Somehing is not working as expected labels Oct 21, 2025
@loki-gh-app loki-gh-app bot requested a review from a team as a code owner October 21, 2025 08:10
@loki-gh-app loki-gh-app bot added size/M backport type/bug Somehing is not working as expected labels Oct 21, 2025
@loki-gh-app loki-gh-app bot requested a review from chaudum October 21, 2025 08:10
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant