pulumi / pulumi-auth0

An auth0Pulumi resource package, providing multi-language access to Auth0
Apache License 2.0
22 stars 7 forks source link

Deletion of auth0.OrganizationConnections fails with panic #696

Closed smithrobs closed 1 week ago

smithrobs commented 1 week ago

Describe what happened

A pulumi up of the sample program succeeds. A subsequent pulumi destroy fails with a panic.

Happens with @pulumi/auth0 v3.8.3 as well as v2.24.3

Sample program

import * as auth0 from "@pulumi/auth0";

const myConnection_1 = new auth0.Connection("my_connection-1", {
    name: "My-Connection-1", // no spaces
    strategy: "auth0",
});
const myConnection_2 = new auth0.Connection("my_connection-2", {
    name: "My-Connection-2",
    strategy: "auth0",
});

const myOrganization = new auth0.Organization("my_organization", {
    name: "auth0-inc",
    displayName: "Auth0 Inc.",
    branding: {
        logoUrl: "https://example.com/assets/icons/icon.png",
        colors: {
            primary: "#f2f2f2",
            page_background: "#e1e1e1",
        },
    },
});

const one_to_many = new auth0.OrganizationConnections("one-to-many", {
    organizationId: myOrganization.id,
    enabledConnections: [
        {
            connectionId: myConnection_1.id,
            assignMembershipOnLogin: true,
            // DOES NOT EXIST:
            // isSignupEnabled: false,
            // showAsButton: true,
        },
        {
            connectionId: myConnection_2.id,
            assignMembershipOnLogin: true,
            // isSignupEnabled: false,
            // showAsButton: true,
        },
    ],
});

Log output

Diagnostics:
  auth0:index:OrganizationConnections (one-to-many):
    error: error reading from server: EOF

  pulumi:pulumi:Stack (1882-fht-dev):
    error: update failed

    panic: interface conversion: interface {} is nil, not map[string]interface {}
    goroutine 81 [running]:
    github.com/hashicorp/go-cty/cty.Value.GetAttr({{{0x103f92ff0?, 0x14000116560?}}, {0x0?, 0x0?}}, {0x103a630fd, 0x13})
        /home/runner/go/pkg/mod/github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320/cty/value_ops.go:711 +0x258
    github.com/auth0/terraform-provider-auth0/internal/auth0/organization.deleteOrganizationConnections({0x103f92cf8?, 0x1049935a0?}, 0x140000c6700, {0x103dd1ae0?, 0x140001a1e70?})
        /home/runner/work/pulumi-auth0/pulumi-auth0/upstream/internal/auth0/organization/resource_connections.go:181 +0xec
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).delete(0x140005a60e0, {0x103f92cf8, 0x1049935a0}, 0xd?, {0x103dd1ae0, 0x140001a1e70})
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230710100801-03a71d0fca3d/helper/schema/resource.go:789 +0xe8
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140005a60e0, {0x103f92cf8, 0x1049935a0}, 0x1400040add0, 0x140000c6480, {0x103dd1ae0, 0x140001a1e70})
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230710100801-03a71d0fca3d/helper/schema/resource.go:838 +0x470
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.Apply({0x14000054060?, {0x0?, 0x140004b3601?, 0x14000272960?}}, {0x103a72f51, 0x1e}, {0x103f92e30?, 0x140003982d0}, {0x103f9a5e0?, 0x140000c6480})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.59.0/pkg/tfshim/sdk-v2/provider.go:100 +0x140
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Delete(0x1400021f600, {0x103f93178?, 0x14000272c30?}, 0x14000780180)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.59.0/pkg/tfbridge/provider.go:1036 +0x340
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Delete_Handler.func1({0x103f93178, 0x14000272c30}, {0x103eb95a0?, 0x14000780180})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.81.0/proto/go/provider_grpc.pb.go:627 +0x74
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x103f93178, 0x14000272150}, {0x103eb95a0, 0x14000780180}, 0x1400003a0a0, 0x14000398120)
        /home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x2e8
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Delete_Handler({0x103f43d00?, 0x1400021f600}, {0x103f93178, 0x14000272150}, 0x14000252070, 0x14000404a40)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.81.0/proto/go/provider_grpc.pb.go:629 +0x12c
    google.golang.org/grpc.(*Server).processUnaryRPC(0x14000400000, {0x103f9bb60, 0x14000103860}, 0x14000444000, 0x14000572150, 0x10494d588, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:1360 +0xc04
    google.golang.org/grpc.(*Server).handleStream(0x14000400000, {0x103f9bb60, 0x14000103860}, 0x14000444000, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:1737 +0x7c4
    google.golang.org/grpc.(*Server).serveStreams.func1.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:982 +0x84
    created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 53
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:980 +0x154

Affected Resource(s)

auth0.OrganizationConnections

Output of pulumi about

pulumi about
CLI          
Version      3.138.0
Go Version   go1.23.2
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  auth0   2.24.3
language  nodejs  unknown

Host     
OS       darwin
Version  14.6.1
Arch     arm64

This project is written in nodejs: executable='/Users/rsmith/.nvm/versions/node/v20.15.1/bin/node' version='v20.15.1'

Current Stack: rsmith-pulumi-corp/<stack>/dev

TYPE                                                         URN
pulumi:pulumi:Stack                                          urn:pulumi:dev::<stack>::pulumi:pulumi:Stack::<stack>-dev
pulumi:providers:auth0                                       urn:pulumi:dev::<stack>::pulumi:providers:auth0::default_2_24_3
auth0:index/organization:Organization                        urn:pulumi:dev::<stack>::auth0:index/organization:Organization::my_organization
auth0:index/connection:Connection                            urn:pulumi:dev::<stack>::auth0:index/connection:Connection::my_connection-2
auth0:index/connection:Connection                            urn:pulumi:dev::<stack>::auth0:index/connection:Connection::my_connection-1
auth0:index/organizationConnections:OrganizationConnections  urn:pulumi:dev::<stack>::auth0:index/organizationConnections:OrganizationConnections::one-to-many

Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/rsmith-pulumi-corp
User           rsmith-pulumi-corp
Organizations  rsmith-pulumi-corp
Token type     personal

Dependencies:
NAME            VERSION
@pulumi/auth0   2.24.3
@pulumi/pulumi  3.138.0
@types/node     18.19.64
typescript      5.6.3

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

VenelinMartinov commented 1 week ago

Thanks for reporting @smithrobs. I just tried to repro in TF and it wasn't able to:

terraform {
  required_providers {
    auth0 = {
      source  = "auth0/auth0"
      version = ">= 1.0.0"
    }
  }
}

resource "auth0_connection" "my_connection_1" {
  name     = "My-Connection-1"
  strategy = "auth0"
}

resource "auth0_connection" "my_connection_2" {
  name     = "My-Connection-2"
  strategy = "auth0"
}

resource "auth0_organization" "my_organization" {
  name         = "auth0-inc"
  display_name = "Auth0 Inc."

  branding {
    logo_url = "https://example.com/assets/icons/icon.png"
  }
}

resource "auth0_organization_connections" "one_to_many" {
  organization_id = auth0_organization.my_organization.id

  enabled_connections {
    connection_id             = auth0_connection.my_connection_1.id
    assign_membership_on_login = true
  }

  enabled_connections {
    connection_id             = auth0_connection.my_connection_2.id
    assign_membership_on_login = true
  }
}

Seems to either be a bug with the Pulumi provider or the bridge. Will investigate.

VenelinMartinov commented 1 week ago

Tried reproducing with a stack created with v3.8.3 and the bug does not repro. Will attempt to repro with a stack created with v2, might be something related to state migrations.

VenelinMartinov commented 1 week ago

This seems to be an issue with v2.24.3. The latest pulumi-auth0 (v3.8.3) is not affected.

Note that in order to use the latest version for the destroy you need to:

  1. Edit you package.json to use 3.8.3 for the auth0 package
  2. Run npm i to install the package
  3. Run pulumi up with the newest version in order to change the provider for all resources. Without these steps the resources would still use the old 2.24.3 provider
  4. Run pulumi down in order to delete the resources.

@smithrobs can you please try that and report back if it works?

smithrobs commented 1 week ago

@VenelinMartinov Confirmed v3.8.3 does not panic after having the provider changed for real. Thank you!