frontegg / terraform-provider-frontegg

Terraform Provider for Frontegg
Mozilla Public License 2.0
8 stars 15 forks source link

custom_domain logic appears borked #128

Closed jubrad closed 10 months ago

jubrad commented 10 months ago

The custom domain logic is not working, particularly, in the case that the Post to create it works on the very first attempt (no dns propigation issues), the value for validate is set to false regardless of this success, and the err is set to nil. This results in doing daig.FromErr(err) where err is nil, which is simply not allowed, and completely breaks in the case of TF bridge. Further... the Post command will perform cname (and txt?) validation on the custom_domain so if it succeeds we don't need to retry or check for validation.

Terraform version

running / testing this through the pulumi bridge v0.2.31

Affected resources

Debug Output

I added some error logging to determine where this was occuring, don't be alarmed by the error messages, except error: expected non-nil error with nil state during Create of urn:... and the subsequent panic.

 frontegg:index:Workspace (frontegg):
    error:   provider/resource_frontegg_workspace.go:1438: provider: Updating workspace: provider="frontegg@0.2.30-alpha.1699912718+62f1f83b.dirty"
    error:   provider/resource_frontegg_workspace.go:1456: provider: updating workspace custom domains: provider="frontegg@0.2.30-alpha.1699912718+62f1f83b.dirty"
    error: expected non-nil error with nil state during Create of urn:...

  pulumi:pulumi:Stack (justin3):
    warning: using pulumi-resource-frontegg from $PATH at /Users/justin/go/bin/pulumi-resource-frontegg
    warning: using pulumi-resource-frontegg from $PATH at /Users/justin/go/bin/pulumi-resource-frontegg
    warning: using pulumi-resource-frontegg from $PATH at /Users/justin/go/bin/pulumi-resource-frontegg
    warning: using pulumi-resource-frontegg from $PATH at /Users/justin/go/bin/pulumi-resource-frontegg
    error: update failed

    panic: interface conversion: interface {} is nil, not map[string]interface {}
    goroutine 623 [running]:
    github.com/hashicorp/go-cty/cty.Value.GetAttr({{{0x110ff2ad0?, 0x1400ed97230?}}, {0x0?, 0x0?}}, {0x10ca9966f, 0x8})
        /home/runner/go/pkg/mod/github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320/cty/value_ops.go:711 +0x258
    github.com/hashicorp/terraform-provider-aws/internal/provider.tagsResourceInterceptor.run({0x14000fddf20?, 0x110e96aa0?, 0x110e96a98?}, {0x110ff26a8, 0x1400c340720}, {0x111003218, 0x1400edf8780}, {0x110e35440?, 0x140030208c0?}, 0x1, ...)
        /home/runner/work/pulumi-aws/pulumi-aws/upstream/internal/provider/intercept.go:250 +0xea4
    github.com/hashicorp/terraform-provider-aws/internal/provider.New.(*wrappedResource).Update.interceptedHandler[...].func10(0x0?, {0x110e35440?, 0x140030208c0?})
        /home/runner/work/pulumi-aws/pulumi-aws/upstream/internal/provider/intercept.go:100 +0x11c
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x110ff2788?, {0x110ff2788?, 0x11ba59f20?}, 0xd?, {0x110e35440?, 0x140030208c0?})
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230912190043-e6d96b3b8f7e/helper/schema/resource.go:812 +0x64
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140011c4540, {0x110ff2788, 0x11ba59f20}, 0x140087f6dd0, 0x1400eb69f00, {0x110e35440, 0x140030208c0})
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230912190043-e6d96b3b8f7e/helper/schema/resource.go:924 +0x658
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.Apply({0x14000b8fc20?, {0x1400079d730?, 0x1400edd5440?, 0x0?}}, {0x10caf3320, 0x12}, {0x110ff2bb8?, 0x1400ebece40}, {0x111002ce0?, 0x1400eb69f00})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.60.2-0.20230927165309-e3fd9503f2d3/pkg/tfshim/sdk-v2/provider.go:100 +0x140
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Update(0x140002862c0, {0x110ff26a8?, 0x1400bf96000?}, 0x1400becebd0)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.60.2-0.20230927165309-e3fd9503f2d3/pkg/tfbridge/provider.go:975 +0x6d0
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Update.func1({0x111020fb8?, 0x140002862c0?})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.7-0.20230801203955-5d215c892096/muxer.go:356 +0x3c
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.resourceMethod[...](0x14001e02eb0?, 0x1400bd5b788, 0x1400bd5b768?)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.7-0.20230801203955-5d215c892096/muxer.go:303 +0xc4
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Update(0x1400bd5b7c8?, {0x110ff26a8?, 0x1400bf96000?}, 0x10e99f6e0?)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.7-0.20230801203955-5d215c892096/muxer.go:355 +0x5c
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Update_Handler.func1({0x110ff26a8, 0x1400bf96000}, {0x110a45660?, 0x1400becebd0})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.81.0/proto/go/provider_grpc.pb.go:609 +0x74
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x110ff26a8, 0x14001d9d200}, {0x110a45660, 0x1400becebd0}, 0x1400ebf4440, 0x1400ebec918)
        /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_Update_Handler({0x110ca22e0?, 0x14001e02eb0}, {0x110ff26a8, 0x14001d9d200}, 0x1400ebbb570, 0x1400c3f49c0)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.81.0/proto/go/provider_grpc.pb.go:611 +0x12c
    google.golang.org/grpc.(*Server).processUnaryRPC(0x1400045c3c0, {0x111005080, 0x1400953e9c0}, 0x1400e8ebc20, 0x14001cd4a80, 0x11ba06b10, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:1360 +0xc04
    google.golang.org/grpc.(*Server).handleStream(0x1400045c3c0, {0x111005080, 0x1400953e9c0}, 0x1400e8ebc20, 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 56
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:980 +0x154

Expected Behavior

It should create, or successfully re-create the custom domain or appropriately error.

Actual Behavior

The function attempts to return diag.FromErr(nil) when the expected output type of resourceFronteggWorkspaceUpdate is diag.Diagnostic, and not allowed to be nil. It does this despite successfully creating the custom_domain.

Steps to reproduce

These will hit a different code path, one requiring post retries, the other succeeding on the initial post.

References

The bug was introduced in this PR https://github.com/frontegg/terraform-provider-frontegg/pull/118/files