grafana / scenes

Build Grafana dashboards directly in your Grafana app plugins.
https://grafana.com/developers/scenes
Apache License 2.0
133 stars 20 forks source link

Commas in variable values break URL sync and interpolation #683

Open rdubrock opened 5 months ago

rdubrock commented 5 months ago

A variable value that has a comma in it will end up getting cut off. I think this happens as a result of how values are getting serialized in the URL. To reproduce use a URL with a comma as the variable value:

const value = "https://www.example.com/?ll=39.383,-29.238&radius=2000"
const myVar = new CustomVariable({
      name: 'myVar',
      query: value,
      value,
    });

console.log(myVar.getValue()) // Will log out the correct value

However, the resulting variable will show up malformed in the URL:

...&var-myVar=https:%2F%2Fwww.example.com%3Fll%3D39.383&from=now-1h&to=now

Other URL unsafe characters are escaped, but a comma just results in the value getting cut off. This malformed version of the value is what ends up getting interpolated into queries, which fail as a result.