You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozhera.apache.org by "itlemon (via GitHub)" <gi...@apache.org> on 2026/09/02 07:36:12 UTC

[PR] fix: encode Prometheus query params to preserve '+' in label values [ozhera]

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: commits-unsubscribe@ozhera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozhera.apache.org
For additional commands, e-mail: commits-help@ozhera.apache.org


Re: [PR] fix: encode Prometheus query params to preserve '+' in label values [ozhera]

Posted by "sadadw1 (via GitHub)" <gi...@apache.org>.
sadadw1 merged PR #689:
URL: https://github.com/apache/ozhera/pull/689


-- 
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: commits-unsubscribe@ozhera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozhera.apache.org
For additional commands, e-mail: commits-help@ozhera.apache.org