sdk
sdk copied to clipboard
Missing default values for Time breaks grafana 6.7.2
The Board type contains a Time structure, which has two strings in it. If you don't fill those strings in, and you try to just create a simple board (following roughly the sample code in the README), the call succeeds but the resulting board gives a javascript error because Grafana thinks the board has a timerange but there are no from or to values.
Specifically, on line 55 of grafana's template_srv.ts, we have:
const from = this.timeRange.from.valueOf().toString();
The structure this.Timerange is not null, but this.timeRange.from is undefined.
This means that very simple code like:
board := grafana.NewBoard("MY TITLE")
row := board.AddRow("MY ROW")
row.Add(grafana.NewGraph("MY GRAPH"))
response, err := client.SetDashboard(context.Background(), *board, grafana.SetDashboardParams{
Overwrite: true,
})
creates a board that breaks Grafana's front end.
This is more a bug with Grafana's API than anything else, but the SDK should work around it IMO.
The
Boardtype contains aTimestructure, which has two strings in it. If you don't fill those strings in, and you try to just create a simple board (following roughly the sample code in the README), the call succeeds but the resulting board gives a javascript error because Grafana thinks the board has a timerange but there are nofromortovalues.Specifically, on line 55 of grafana's
template_srv.ts, we have:const from = this.timeRange.from.valueOf().toString();The structure
this.Timerangeis not null, butthis.timeRange.fromisundefined.This means that very simple code like:
board := grafana.NewBoard("MY TITLE") row := board.AddRow("MY ROW") row.Add(grafana.NewGraph("MY GRAPH")) response, err := client.SetDashboard(context.Background(), *board, grafana.SetDashboardParams{ Overwrite: true, })creates a board that breaks Grafana's front end.
This is more a bug with Grafana's API than anything else, but the SDK should work around it IMO.
I wonder what kind of default values Grafana sets for these. Will need to investigate. Perhaps you know? Also, is there some kind of upstream bug report about this?