Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Fix escaped characters bug #2198

Merged
merged 5 commits into from
Nov 29, 2022
Merged

ui: Fix escaped characters bug #2198

merged 5 commits into from
Nov 29, 2022

Conversation

yomete
Copy link
Contributor

@yomete yomete commented Nov 29, 2022

This PR fixes a bug where an inclusion of escaped characters in the parca.yaml file causes the profiler not to work as expected. To fix, we replace single \ in the labelValues string with doubles \\ if available and this is done on 3 levels:

  1. When the label values are fetched for a label name during autocomplete suggestion
  2. When a user clicks on any sample in the MetricsGraph to view a profile and
  3. When a user clicks on any of the labels on the MetricsGraph tooltip

Resolves #1060

@yomete yomete requested a review from a team as a code owner November 29, 2022 07:06
setLabelValues(response.labelValues);
// replace single `\` in the `labelValues` string with doubles `\\` if available.
const newValues = response.labelValues.map(value =>
value.includes('\\') ? value.replace('\\', '\\\\') : value
Copy link
Contributor

Choose a reason for hiding this comment

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

I belive the string.replace will only replace the first matching pattern, so it wouldn't handle a second occurrence of \\ in the string.
I am not sure if multiple escape characters is a possibility here, but just in case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, Should we extract this into a sanitizeLabelValue function in @parca/functions package and use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I just figured that was a possibility. making a change now

Copy link
Contributor

Choose a reason for hiding this comment

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

It's great that the CodeQL scanner captured it too. 😀

Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

Nice work!! Works perfectly now. lgtm 👍 🎉

@brancz brancz merged commit 04be1a7 into main Nov 29, 2022
@brancz brancz deleted the escaping-labels branch November 29, 2022 08:53
@rafaeljesus
Copy link

is there a docker image / release I could use with this fix?

@brancz
Copy link
Member

brancz commented Dec 1, 2022

Yep! There's always an image built from main. We're actually running main-9b7a8c94 on the demo cluster right now, which has a ton of other really good improvements, I would suggest to try that one!

fabxc pushed a commit to fabxc/parca that referenced this pull request Dec 5, 2022
* ui: Fix escaped characters bug

* Use `replaceAll` to switch characters

* Fix linting errors

Co-authored-by: Manoj Vivek <p.manoj.vivek@gmail.com>
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.

could not find profile at requested time and selectors
4 participants