Skip to content

Bug: Fix tag values handling with special characters#6212

Merged
joe-elliott merged 9 commits intografana:mainfrom
joe-elliott:fix-things
Jan 15, 2026
Merged

Bug: Fix tag values handling with special characters#6212
joe-elliott merged 9 commits intografana:mainfrom
joe-elliott:fix-things

Conversation

@joe-elliott
Copy link
Copy Markdown
Collaborator

What this PR does:
Tempo doesn't handle tag value lookups when special characters are present in the tag value very well. This PR adds support for special characters and adds an integration test to pin this behavior. There are some ticky-tacky changes in this PR to tag path parsing but the integration test should hold everything in place.

Also changed our http client to mimic the way Grafana builds urls when calling Tempo. This will help keep our integration tests "honest" with our most important client. See the integration tests and http client changes for details.

Finally, I was not able to find a solution for attributes containing a double forward slash //. The router itself seemed to eat one of the slashes and normalize the path to only have one. This will require more digging.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Comment thread pkg/httpclient/client.go
}

// the use of path.Join, not escaping the key and the specific way the url is parsed is all very purposeful here
// to mimic how Grafana builds URLs when calling Tempo so our integration tests mimic our most important client
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather unfortunate

tagNameRegexV1 = regexp.MustCompile(`.*/api/search/tag/([^/]+)/values`)
tagNameRegexV2 = regexp.MustCompile(`.*/api/v2/search/tag/([^/]+)/values`)
tagNameRegexV1 = regexp.MustCompile(`.*/api/search/tag/(.+)/values`)
tagNameRegexV2 = regexp.MustCompile(`.*/api/v2/search/tag/(.+)/values`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I construct an attribute with key=maliciousAttribute/api/search/tag/?

Copy link
Copy Markdown
Contributor

@oleg-kozlyuk-grafana oleg-kozlyuk-grafana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that there are layers of legacy behaviors here that are hard to untangle. Ideally, of course, regex should be eliminated - but the ROI on this effort would be too low.

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott joe-elliott merged commit 822598f into grafana:main Jan 15, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants