Skip to content

Commit

Permalink
azurerm_mobile_network: fix a potenial crash (#25363)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyeqf authored Mar 22, 2024
1 parent 22cc9c9 commit f93702e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/services/mobilenetwork/mobile_network_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func (r MobileNetworkResource) Arguments() map[string]*pluginsdk.Schema {
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^\d{3}$`),
"Mobile country code should be three digits.",
)},
),
},

"mobile_network_code": {
Type: pluginsdk.TypeString,
Expand All @@ -74,7 +75,8 @@ func (r MobileNetworkResource) Arguments() map[string]*pluginsdk.Schema {
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^\d{2,3}$`),
"Mobile network code should be two or three digits.",
)},
),
},

"tags": commonschema.Tags(),
}
Expand Down Expand Up @@ -247,7 +249,7 @@ func (r MobileNetworkResource) Delete() sdk.ResourceFunc {
Refresh: func() (result interface{}, state string, err error) {
resp, err := client.Delete(ctx, *id)
if err != nil {
if resp.HttpResponse.StatusCode == http.StatusConflict {
if resp.HttpResponse != nil && resp.HttpResponse.StatusCode == http.StatusConflict {
return nil, "409", nil
}
return nil, "", err
Expand Down

0 comments on commit f93702e

Please sign in to comment.