sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Missing default values for Time breaks grafana 6.7.2

Open Humper opened this issue 5 years ago • 1 comments
trafficstars

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.

Humper avatar Apr 13 '20 14:04 Humper

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.

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?

GiedriusS avatar Apr 14 '20 19:04 GiedriusS