grafana / grafana-json-datasource

A data source plugin for loading JSON APIs into Grafana.
Apache License 2.0
270 stars 66 forks source link

Query params are duplicated #97

Open TimUnderhay opened 3 years ago

TimUnderhay commented 3 years ago

I've just discovered an interesting problem (using version 1.1.1): all query parameters specified in the query params tab arrive at my REST API wrapped in an array, with a double value (edit: not actually wrapped in an array: each query param is listed twice). For example:

image

With a simple node express app, if I dump the request query params to the console, this is what shows up:

app.get('/test', (req, res, next) => {
  console.log('query:', req.query);
  res.status(200).send('ok');
}

Yields:

  time1: [ '1618424054', '1618424054' ],
  time2: [ '1619028854', '1619028854' ]
}
TimUnderhay commented 3 years ago

This is the URL that is being called by the plugin:

/test?time1=1618424054&time2=1619028854&time1=1618424054&time2=1619028854

marcusolsson commented 3 years ago

That looks weird indeed 🤔 I'll try to troubleshoot this in the coming days. Thanks for reporting!

TimUnderhay commented 3 years ago

I had a deep-ish look at this myself. I don't think the problem is in your code -- I think it's the underlying Grafana fetch function that has a bug. When the request gets handed off to getBackendSrv().fetch(req), the query params all seem to be correct.