itlemon opened a new pull request, #689:
URL: https://github.com/apache/ozhera/pull/689
## Problem
When a Prometheus label value contains a `+` (e.g. `serverEnv=...+c3`),
queries via `/prometheus/queryIncrease` (and other `getHttpM`-based queries)
return no data even though the data exists.
## Root cause
`RestTemplateService.getHttpM` relied on RestTemplate URI template variable
expansion (`?query={query}&...`), which keeps a literal `+` in the query
string. Prometheus then decodes `+` as a space per
`application/x-www-form-urlencoded`, so a label value containing `+` fails
exact matching (`...+c3` becomes `... c3`) and the query returns no data.
## Fix
- Encode each query parameter value exactly once via
`UriUtils.encodeQueryParam` (`+` becomes `%2B`, space becomes `%20`) and pass a
pre-encoded `URI` to `getForObject`/`exchange` so RestTemplate does not
expand/encode it again (avoids double encoding).
- Also fixes the `ali` branch, which previously called `exchange(url, ...)`
without passing the template variables, leaving the `{query}` placeholder
unresolved.
## Verification
Tested directly against Prometheus:
- `+` encoded as `%2B` -> returns data ✓
- literal `+` or a space -> returns no data ✗ (reproduces the bug)
- double-encoded (`%252B`) -> HTTP 400 (confirms encoding must happen only
once)
All 15 `getHttpM` call sites were reviewed: every value passed in is a raw
(un-encoded) PromQL string or a number/boolean, so there is no double-encoding
risk, and the base URL never contains a query string.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]