Repository navigation
fix: base64-encode "." and ".." in Pushgateway URL path segments - #2633
Open
sarankumar1325 wants to merge 1 commit into
Open
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
A job name or grouping key value of "." or ".." was appended to the URL
as is, and URI.normalize() then removed it as a dot segment. For job "j"
with grouping key {instance=".."} the request went to /metrics/job/j/,
and with {instance="."} to /metrics/job/j/instance/, so the push or
delete never reaches the intended group. Base64-encode these values, as
client_golang does.
Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
sarankumar1325
requested review from
dhoard,
fstab,
jaydeluca and
zeitlinger
as code owners
October 31, 2026 16:32
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PushGateway.makeUrl()appends a job name or grouping key value of.or..to the path unchanged (URLEncoderleaves dots alone). After that,URI.normalize()removes it as a dot segment, so the request goes to a different path:j/{instance=".."}/metrics/job/j/j/{instance="."}/metrics/job/j/instance/../{instance="x"}/metrics/instance/xIn every case the push or delete misses the intended group. This change base64-encodes these values with the
@base64suffix, the same way values containing/are already handled, and client_golang does the same. Paths for all other values stay the same.Tests:
PushGatewayTest#testPushWithDotSegmentJobAndGroupingKey, which expects/metrics/job@base64/Li4=/l@base64/Lg==/l2@base64/Li4=. It fails on main (the mock server gets an unmatched request and returns 404) and passes with this change../mvnw -pl prometheus-metrics-exporter-pushgateway verify -Dcoverage.skip=truepasses (31 tests, Error Prone included), and the changed lines are google-java-format clean.I used an AI assistant while preparing this change. I reviewed and tested it myself.