Tempo: Correctly escape/unescape tag when looking for tag values (#114275)

* Correctly escape/unescape tag

Signed-off-by: Joe Elliott <number101010@gmail.com>

* changelog

Signed-off-by: Joe Elliott <number101010@gmail.com>

* Revert "changelog"

This reverts commit e0cde18994c67fbdd601514d2f930798b0ae76c6.

---------

Signed-off-by: Joe Elliott <number101010@gmail.com>
This commit is contained in:
Joe Elliott
2025-12-15 10:41:24 +01:00
committed by GitHub
parent 0c49337205
commit 4149767391
2 changed files with 10 additions and 4 deletions
+9 -1
View File
@@ -280,7 +280,15 @@ func (s *Service) handleTagValues(rw http.ResponseWriter, req *http.Request) {
return
}
tempoPath := fmt.Sprintf("api/v2/search/tag/%s/values", encodedTag)
// escape tag
tag, err := url.PathUnescape(encodedTag)
if err != nil {
s.logger.Error("Failed to unescape", "error", err, "tag", encodedTag)
http.Error(rw, "Invalid 'tag' parameter", http.StatusBadRequest)
return
}
tempoPath := fmt.Sprintf("api/v2/search/tag/%s/values", tag)
s.proxyToTempo(rw, req, tempoPath)
}
@@ -190,9 +190,7 @@ export default class TempoLanguageProvider extends LanguageProvider {
* @returns the encoded tag
*/
private encodeTag = (tag: string): string => {
// If we call `encodeURIComponent` only once, we still get an error when issuing a request to the backend
// Reference: https://stackoverflow.com/a/37456192
return encodeURIComponent(encodeURIComponent(tag));
return encodeURIComponent(tag);
};
generateQueryFromFilters({