Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -11106,8 +11106,7 @@ func buildTerraformNumberFormatFormulaSchema(datadogStyle datadogV1.WidgetNumber
m["unit"] = []map[string]interface{}{unit}
}
if v, ok := datadogStyle.GetUnitScaleOk(); ok {
unitScale := map[string]interface{}{}
unitScale["unit_name"] = []map[string]interface{}{{"unit_name": v.UnitName}}
unitScale := map[string]interface{}{"unit_name": v.UnitName}
m["unit_scale"] = []map[string]interface{}{unitScale}
Copy link
Author

@brlee19 brlee19 Sep 19, 2025

Choose a reason for hiding this comment

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

The schema for this is:

"unit_scale": &schema.Schema{
			Description: "",
			Type:        schema.TypeList,
			MinItems:    0,
			MaxItems:    1,
			Optional:    true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"unit_name": &schema.Schema{
						Description: "",
						Type:        schema.TypeString,
						Required:    true,
					},
				},
			},
		},

so m["unit_scale"] is supposed to contain a list of map[string]string if I am reading this right, not another map containing "unit_name" as a key

Copy link
Author

@brlee19 brlee19 Sep 19, 2025

Choose a reason for hiding this comment

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

The old code appears to be the cause of the error per the CI output:

level=fatal msg="Execution failed" error="error: error generating plan: exit status 1\n\nError: widget.1.group_definition.0.widget.0.query_value_definition.0.request.0.formula.0.number_format.0.unit_scale.0.unit_name: '' expected type 'string', got unconvertible type '[]map[string]interface {}', value: '[map[unit_name:0xc0009716e0]]'\n\n with datadog_dashboard.maze_api_dashboard,\n on dashboard.tf line 1, in resource \"datadog_dashboard\" \"maze_api_dashboard\":\n 1: resource \"datadog_dashboard\" \"maze_api_dashboard\" {\n\n code: INVALID_ARGUMENT origin: terraform-invocation, action: plan, cause: USER, resource: \n"

aka it is saying that the first element of unit_scale had a []map[string]interface {}' at its unit_name key and not just a string

Copy link
Author

Choose a reason for hiding this comment

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

I am not sure why the old code was working until Wednesday though this probably has something to do with the new release that day.

}
return []map[string]interface{}{m}
Expand Down
Loading