Skip to content

Commit

Permalink
fix: Fixes nil pointer dereference if advanced_configuration update…
Browse files Browse the repository at this point in the history
… fails in `mongodbatlas_cluster` (#2139)
  • Loading branch information
maastha authored Apr 12, 2024
1 parent 108b8a1 commit 2e93b26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/2139.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/mongodbatlas_cluster: Fixes nil pointer dereference if `advanced_configuration` update fails
```
10 changes: 6 additions & 4 deletions internal/service/cluster/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ import (
"strings"
"time"

matlas "go.mongodb.org/atlas/mongodbatlas"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/spf13/cast"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster"
"github.com/spf13/cast"
matlas "go.mongodb.org/atlas/mongodbatlas"
)

const (
Expand Down Expand Up @@ -926,9 +928,9 @@ func resourceMongoDBAtlasClusterUpdate(ctx context.Context, d *schema.ResourceDa
if aclist, ok1 := ac.([]any); ok1 && len(aclist) > 0 {
advancedConfReq := expandProcessArgs(d, aclist[0].(map[string]any))
if !reflect.DeepEqual(advancedConfReq, matlas.ProcessArgs{}) {
argResp, _, err := conn.Clusters.UpdateProcessArgs(ctx, projectID, clusterName, advancedConfReq)
_, _, err := conn.Clusters.UpdateProcessArgs(ctx, projectID, clusterName, advancedConfReq)
if err != nil {
return diag.FromErr(fmt.Errorf(errorAdvancedConfUpdate, clusterName+argResp.DefaultReadConcern, err))
return diag.FromErr(fmt.Errorf(errorAdvancedConfUpdate, clusterName, err))
}
}
}
Expand Down

0 comments on commit 2e93b26

Please sign in to comment.