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

Fix potential panic on dashboards #931

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

julienduchesne
Copy link
Member

Closes #921

@julienduchesne julienduchesne requested a review from a team as a code owner June 5, 2023 13:51
@github-actions
Copy link

github-actions bot commented Jun 5, 2023

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. To do so, a Grafana Labs employee must promote the Drone build.

For maintainers, it's better to run only the Cloud tests you need, rather than all of them. You can do so by setting the following parameter when promoting:

TESTARGS='-run=<testname>'

@@ -362,7 +362,7 @@ func NormalizeDashboardConfigJSON(config interface{}) string {
// from the dashboard JSON other than "name" or "uid".
// Grafana will populate all other libraryPanel attributes, so delete them to avoid diff.
panels, hasPanels := dashboardJSON["panels"]
if hasPanels {
if hasPanels && panels != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is:

panic: interface conversion: interface {} is nil, not []interface {}

Wouldn't perhaps the right check be?

Suggested change
if hasPanels && panels != nil {
if _, ok := pabels.([]interface{}); ok && hasPanels {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasPanels is useless in that case. I think we only need the cast in fact: https://go.dev/play/p/qCqc3sQfkNk

@julienduchesne julienduchesne requested a review from inkel June 6, 2023 13:31
Copy link
Contributor

@inkel inkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer!

@julienduchesne julienduchesne merged commit 40140ce into master Jun 6, 2023
@julienduchesne julienduchesne deleted the julienduchesne/fix-nil-panels branch June 6, 2023 13:34
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.

The terraform-provider-grafana_v1.40.1 plugin crashed!
2 participants