vmware / terraform-provider-tanzu-mission-control

Terraform provider to manage resources of Tanzu Mission Control
Mozilla Public License 2.0
38 stars 31 forks source link

Fix deref for dataprotection resource #388

Closed rnarenpujari closed 5 months ago

rnarenpujari commented 5 months ago
  1. What this PR does / why we need it:

Fixes incorrect deref in case the meta field is not set in the dataprotection resource.

Stack trace from the terraform-provider-tanzu-mission-control_v1.4.3 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 332 [running]:
github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/dataprotection.resourceEnableDataProtectionRead({0x1f611c0, 0xc00085b650}, 0xc0005b0680, {0x1b57c60?, 0xc000312420})
    github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/dataprotection/resource_enable_data_protection.go:71 +0x448
github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/dataprotection.resourceEnableDataProtectionCreate({0x1f61188, 0xc0006a6a20}, 0x19e1d40?, {0x1b57c60?, 0xc000312420?})
    github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/dataprotection/resource_enable_data_protection.go:56 +0x226
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc000602b60, {0x1f611c0, 0xc0002d8bd0}, 0xd?, {0x1b57c60, 0xc000312420})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.16.0/helper/schema/resource.go:707 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000602b60, {0x1f611c0, 0xc0002d8bd0}, 0xc0006f48f0, 0xc000169f00, {0x1b57c60, 0xc000312420})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.16.0/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0005fc450, {0x1f61118?, 0xc000539600?}, 0xc000828d20)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.16.0/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0003d1a40, {0x1f611c0?, 0xc0002d83f0?}, 0xc000641b90)
    github.com/hashicorp/terraform-plugin-go@v0.9.0/tfprotov5/tf5server/server.go:812 +0x515
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1b71ce0?, 0xc0003d1a40}, {0x1f611c0, 0xc0002d83f0}, 0xc000641b20, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.9.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003101e0, {0x1f68098, 0xc0001029c0}, 0xc00094e7e0, 0xc0005ff110, 0x2d54000, 0x0)
    google.golang.org/grpc@v1.56.3/server.go:1335 +0xdf0
google.golang.org/grpc.(*Server).handleStream(0xc0003101e0, {0x1f68098, 0xc0001029c0}, 0xc00094e7e0, 0x0)
    google.golang.org/grpc@v1.56.3/server.go:1712 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.56.3/server.go:947 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.56.3/server.go:958 +0x15c

Error: The terraform-provider-tanzu-mission-control_v1.4.3 plugin crashed!

Acceptance tests passed for the resource: Screenshot 2024-03-20 at 3 28 40 PM

  1. Which issue(s) this PR fixes

    (optional, in `fixes #<issue number>` format, will close the issue(s) when PR gets merged):
    
    Fixes #
  2. Additional information

  3. Special notes for your reviewer

vmwclabot commented 5 months ago

@rnarenpujari, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 25.23%. Comparing base (73e4875) to head (7c1f28d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #388 +/- ## ======================================= Coverage 25.23% 25.23% ======================================= Files 195 195 Lines 16908 16908 ======================================= Hits 4267 4267 Misses 12423 12423 Partials 218 218 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

eastaga commented 5 months ago

lgtm

rnarenpujari commented 5 months ago

TFTR