Skip to content

Commit 1000e58

Browse files
authored
Validate widgets cast in dashboard JSON (#1197)
The data structure may not be complete when StateFunc is called, so we need to assert that the cast works properly. Closes #1196
1 parent 5a5507d commit 1000e58

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

datadog/resource_datadog_dashboard_json.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func resourceDatadogDashboardJSON() *schema.Resource {
5757
delete(attrMap, f)
5858
}
5959
// Remove every widget id too
60-
deleteWidgetID(attrMap["widgets"].([]interface{}))
60+
if widgets, ok := attrMap["widgets"].([]interface{}); ok {
61+
deleteWidgetID(widgets)
62+
}
6163
res, _ := structure.FlattenJsonToString(attrMap)
6264
return res
6365
},

0 commit comments

Comments
 (0)