@@ -812,7 +812,12 @@ func toSwitchPortSettingsModel(settings *oxide.SwitchPortSettings) (switchPortSe
812812 //
813813 // Addresses
814814 //
815- if len (settings .Addresses ) > 0 {
815+ if len (settings .Addresses ) == 0 {
816+ diags .AddError (
817+ "Unexpected empty attribute: addresses" ,
818+ "The API returned an empty array for this required attribute." ,
819+ )
820+ } else {
816821 linkToAddrs := make (map [string ][]switchPortSettingsAddressAddressModel )
817822 for _ , address := range settings .Addresses {
818823 link := string (address .InterfaceName )
@@ -993,7 +998,12 @@ func toSwitchPortSettingsModel(settings *oxide.SwitchPortSettings) (switchPortSe
993998 //
994999 // Links
9951000 //
996- if len (settings .Links ) > 0 {
1001+ if len (settings .Links ) == 0 {
1002+ diags .AddError (
1003+ "Unexpected empty attribute: links" ,
1004+ "The API returned an empty array for this required attribute." ,
1005+ )
1006+ } else {
9971007 linkModels := make ([]switchPortSettingsLinkModel , 0 )
9981008 for _ , link := range settings .Links {
9991009 linkModel := switchPortSettingsLinkModel {
@@ -1152,7 +1162,7 @@ func toSwitchPortSettingsModel(settings *oxide.SwitchPortSettings) (switchPortSe
11521162 return model , diags
11531163}
11541164
1155- // toNetworkingSwitchPortSettingsCreateParams converts [switchPortSettingsModel`
1165+ // toNetworkingSwitchPortSettingsCreateParams converts [switchPortSettingsModel]
11561166// to [oxide.NetworkingSwitchPortSettingsCreateParams]. This is far simpler than
11571167// [toSwitchPortSettingsModel] since the Oxide `switch_port_settings_create` API
11581168// request body matches the Terraform schema.
0 commit comments