Skip to content

[bugfix] preserve special characters in promql queries - #4376

Open
Hanabi9248 wants to merge 2 commits into
apache:masterfrom
Hanabi9248:codex/promql-query-encoding
Open

Hanabi9248 wants to merge 2 commits into
apache:masterfrom
Hanabi9248:codex/promql-query-encoding

Conversation

@Hanabi9248

Copy link
Copy Markdown

What's changed?

PromQL expressions are inserted directly into query parameters, leaving + and & unescaped. The server decodes addition operators and regex quantifiers as spaces, and an ampersand in a label value splits the expression into another parameter. For example, sum(up{job=~"api.+",label="a&b=50%"}) + 1 arrives truncated and altered.

Encode the expression as a URI template value in execute and both instant and range query requests. The regression captures the URI from each actual executor path and checks the server-decoded parameters, including the range bounds and step.

Validation on Windows with Java 25: all 10 query-executor tests pass, including the three new regressions that fail before the fix. Maven Checkstyle and git diff --check pass. The full warehouse suite and a live Prometheus server were not run.

Checklist

  • I have read the contributing guide.
  • The regression test documents the affected query and expected behavior.
  • Added the necessary unit tests; all query-executor tests pass.

Add or update API

No API changes.

Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant