jfrog / terraform-provider-platform

Terraform provider to manage JFrog Platform
https://jfrog.com
Apache License 2.0
1 stars 1 forks source link

Provider crash on upgrade to `1.7.3` #75

Closed braunsonm closed 2 months ago

braunsonm commented 2 months ago

Describe the bug Provider panic's and crashes during terraform plan on version 1.7.3. Downgrading to 1.7.2 works.

Based on the log it seems to be related to this version trying to null out the groups value on any platform_permission that do not define groups. Here is an example from ours

resource "platform_permission" "npm_remote_repo" {
  name = "npm-remote-repo"

  artifact = {
    actions = {
      users = [
        {
          name        = artifactory_user.service_account["my-account"].name
          permissions = ["READ", "WRITE"]
        }
      ]
    }

    targets = [{ name = "my-remote" }]
  }
}

Expected behavior The provider should not crash.

Additional context

Stack trace from the terraform-provider-platform_v1.7.3 plugin:
panic: interface conversion: attr.Value is nil, not basetypes.ObjectValue
goroutine 32 [running]:
github.com/jfrog/terraform-provider-platform/pkg/platform.setUsersGroupsAttributeToNull({0xd87f08, 0xc000686930}, {0x0?, 0xc0007379e0?, 0x20?}, {0xc45b15, 0x5}, 0xc000551680)
    [github.com/jfrog/terraform-provider-platform/pkg/platform/resource_permission.go:278](http://github.com/jfrog/terraform-provider-platform/pkg/platform/resource_permission.go:278) +0x946
[github.com/jfrog/terraform-provider-platform/pkg/platform.(*permissionResource](http://github.com/jfrog/terraform-provider-platform/pkg/platform.(*permissionResource)).UpgradeState.func1({0xd87f08, 0xc000686930}, {0xc00060e0c0?, 0xc0007374d0?}, 0xc000551680)
    [github.com/jfrog/terraform-provider-platform/pkg/platform/resource_permission.go:323](http://github.com/jfrog/terraform-provider-platform/pkg/platform/resource_permission.go:323) +0x335
[github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server](http://github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server)).UpgradeResourceState(0xc00022d040, {0xd87f08, 0xc000686930}, 0xc0006869c0, 0xc00046d6d8)
    [github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/fwserver/server_upgraderesourcestate.go:205](http://github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/fwserver/server_upgraderesourcestate.go:205) +0x96c
[github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server](http://github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server)).UpgradeResourceState(0xc00022d040, {0xd87f08?, 0xc000686810?}, 0xc00060e0e0)
    [github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/proto6server/server_upgraderesourcestate.go:51](http://github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/proto6server/server_upgraderesourcestate.go:51) +0x330
[github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server](http://github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server)).UpgradeResourceState(0xc000241cc0, {0xd87f08?, 0xc000686090?}, 0xc00068e000)
    [github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/tf6server/server.go:744](http://github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/tf6server/server.go:744) +0x278
[github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_UpgradeResourceState_Handler](http://github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_UpgradeResourceState_Handler)({0xc220e0?, 0xc000241cc0}, {0xd87f08, 0xc000686090}, 0xc00068c000, 0x0)
    [github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:446](http://github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:446) +0x169
[google.golang.org/grpc.(*Server](http://google.golang.org/grpc.(*Server)).processUnaryRPC(0xc0001af000, {0xd87f08, 0xc000686000}, {0xd8cf18, 0xc0001c3e00}, 0xc0003c25a0, 0xc0003401b0, 0x127c8b8, 0x0)
    [google.golang.org/grpc@v1.63.2/server.go:1369](http://google.golang.org/grpc@v1.63.2/server.go:1369) +0xe23
[google.golang.org/grpc.(*Server](http://google.golang.org/grpc.(*Server)).handleStream(0xc0001af000, {0xd8cf18, 0xc0001c3e00}, 0xc0003c25a0)
    [google.golang.org/grpc@v1.63.2/server.go:1780](http://google.golang.org/grpc@v1.63.2/server.go:1780) +0x1016
[google.golang.org/grpc.(*Server](http://google.golang.org/grpc.(*Server)).serveStreams.func2.1()
    [google.golang.org/grpc@v1.63.2/server.go:1019](http://google.golang.org/grpc@v1.63.2/server.go:1019) +0x8b
created by [google.golang.org/grpc.(*Server](http://google.golang.org/grpc.(*Server)).serveStreams.func2 in goroutine 13
    [google.golang.org/grpc@v1.63.2/server.go:1030](http://google.golang.org/grpc@v1.63.2/server.go:1030) +0x135
Error: The terraform-provider-platform_v1.7.3 plugin crashed!
alexhung commented 2 months ago

@braunsonm Thanks for the report. I'll investigate.