@@ -812,7 +812,12 @@ func toSwitchPortSettingsModel(settings *oxide.SwitchPortSettings) (switchPortSe
812
812
//
813
813
// Addresses
814
814
//
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 {
816
821
linkToAddrs := make (map [string ][]switchPortSettingsAddressAddressModel )
817
822
for _ , address := range settings .Addresses {
818
823
link := string (address .InterfaceName )
@@ -993,7 +998,12 @@ func toSwitchPortSettingsModel(settings *oxide.SwitchPortSettings) (switchPortSe
993
998
//
994
999
// Links
995
1000
//
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 {
997
1007
linkModels := make ([]switchPortSettingsLinkModel , 0 )
998
1008
for _ , link := range settings .Links {
999
1009
linkModel := switchPortSettingsLinkModel {
@@ -1152,7 +1162,7 @@ func toSwitchPortSettingsModel(settings *oxide.SwitchPortSettings) (switchPortSe
1152
1162
return model , diags
1153
1163
}
1154
1164
1155
- // toNetworkingSwitchPortSettingsCreateParams converts [switchPortSettingsModel`
1165
+ // toNetworkingSwitchPortSettingsCreateParams converts [switchPortSettingsModel]
1156
1166
// to [oxide.NetworkingSwitchPortSettingsCreateParams]. This is far simpler than
1157
1167
// [toSwitchPortSettingsModel] since the Oxide `switch_port_settings_create` API
1158
1168
// request body matches the Terraform schema.
0 commit comments