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

Properly quote string arguments when displaying functions #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ndenev
Copy link

@ndenev ndenev commented May 10, 2024

The Display implementation for Function is not properly quoting string arguments.
For example, doing parse_expr() on this query:

label_replace(metric{label1="value1",label2="value2",label3=~"value3.*"}, "new_label", "$1", "label3", ".*(([0-9]+)).*")

results in this:

label_replace(metric{label1="value1",label2="value2",label3=~"value3.*"}, new_label, $1, label3, .*(([0-9]+)).*)

And with the unquoted arguments, especially the regex reference $1 this fails to parse.

With this change the result is this:

label_replace(metric{label1="value1",label2="value2",label3=~"value3.*"}, "new_label", "$1", "label3", ".*(([0-9]+)).*")

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.

1 participant