pulumi / pulumi-yaml

YAML language provider for Pulumi
Apache License 2.0
38 stars 11 forks source link

panic: interface conversion: interface {} is bool, not string #541

Closed GeoffMillerAZ closed 6 months ago

GeoffMillerAZ commented 6 months ago

What happened?

When passing strings into a gcp:pubsub:Subscription labels, Pulumi yaml panics and crashes to stack trace. Please see the example for much more detail.

Example

# new
name: activtrak-identity-pubsub
runtime: yaml
config:
  vanta_label_contains_user_data:
    type: string
  vanta_label_non_prod:
    type: string

resources:
  identity-change-detection-topic:
    type: gcp:pubsub:Topic
    properties:
      name: identity-change-detection
      project: ${project}
    options:
      protect: true

  identity-change-detection-sub:
    type: gcp:pubsub:Subscription
    properties:
      labels:
        vanta-contains-user-data: ${vanta_label_contains_user_data}
        vanta-description: shared-data-across-services
        vanta-non-prod: ${vanta_label_non_prod}
        vanta-owner: matthew_finlayson
      ackDeadlineSeconds: 10
      expirationPolicy:
        ttl: ""
      messageRetentionDuration: 86400s
      name: identity-change-detection-sub
      project: ${project}
      topic: projects/${project}/topics/identity-change-detection
    options:
      protect: true
      dependsOn:
        - ${identity-change-detection-topic}

  user-topic:
    type: gcp:pubsub:Topic
    properties:
      name: user
      project: ${project}
    options:
      protect: true

  identity-user-creation-sub:
    type: gcp:pubsub:Subscription
    properties:
      labels:
        # vanta-contains-user-data: ${vanta_label_contains_user_data}
        vanta-contains-user-data: "false"
        vanta-description: shared-data-across-services
        # vanta-non-prod: ${vanta_label_non_prod}
        vanta-non-prod: "true"
        vanta-owner: matthew_finlayson
      ackDeadlineSeconds: 10
      expirationPolicy:
        ttl: ""
      messageRetentionDuration: 86400s
      name: identity-user-creation-sub
      project: ${project}
      topic: projects/${project}/topics/user
    options:
      protect: true
      dependsOn:
        - ${user-topic}
config:
  gcp:project: myProject
  activtrak-identity-pubsub:project: myProject
  activtrak-identity-pubsub:vanta_label_contains_user_data: "false"
  activtrak-identity-pubsub:vanta_label_non_prod: "true"

At one point, I was able to get it to work and I got the following output in my plan when I was still trying playing with it.

~ gcp:pubsub/subscription:Subscription: (update) 🔒
    [id=projects/myprojectid/subscriptions/identity-user-creation-sub]
    [urn=urn:pulumi:dev::activtrak-identity-pubsub::gcp:pubsub/subscription:Subscription::identity-user-creation-sub]
  ~ labels: {
      ~ vanta-contains-user-data: "0" => "false"
      ~ vanta-non-prod          : "1" => "true"
    }
~ gcp:pubsub/subscription:Subscription: (update) 🔒
    [id=projects/myprojectid/subscriptions/identity-change-detection-sub]
    [urn=urn:pulumi:dev::activtrak-identity-pubsub::gcp:pubsub/subscription:Subscription::identity-change-detection-sub]
  ~ labels: {
      ~ vanta-contains-user-data: "true" => false
      ~ vanta-non-prod          : "false" => true
    }

What's odd to me is that they are the same resource type, but one is 0 and 1 and "true" and "false", but the other is "true" and "false" and true and false. It's almost as if they are different resource types. They are being passed the same inputs, but they behave differently and store them in the state differently, too. Unfortunately, I am unsure how I even got it to create because I can't get it to do that again. So I can't be certain what state it was in when I saw this. I'm still playing with it. But this should be a provider bug, no? Should I keep playing with it or submit an issue at this point? What do you tell a customer if it's a bug stopping them?

Here is the stacktrace:

Diagnostics:
  pulumi:pulumi:Stack (activtrak-identity-pubsub-dev):
    panic: interface conversion: interface {} is bool, not string
    goroutine 44 [running]:
    github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource.SetLabelsDiff({0x140071766c0?, 0x140071765d0?}, 0x14007144720?, {0x1098f3ee0?, 0x14006cc2a80})
        /home/runner/work/pulumi-gcp/pulumi-gcp/upstream/google-beta/tpgresource/labels.go:84 +0x678
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/pubsub.ResourcePubsubSubscription.All.func1({0x10997ee68, 0x10d7095e0}, 0x10810228f?, {0x1098f3ee0, 0x14006cc2a80})
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230912190043-e6d96b3b8f7e/helper/customdiff/compose.go:53 +0x98
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0x140011dcf60, {0x10997ee68, 0x10d7095e0}, 0x140071244e0, 0x14006ff2f30, 0x140008e0ec0, {0x1098f3ee0, 0x14006cc2a80}, 0x0)
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230912190043-e6d96b3b8f7e/helper/schema/schema.go:698 +0x3b8
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x0?, {0x10997ee68?, 0x10d7095e0?}, 0x140071244e0, 0x140071241a0?, {0x1098f3ee0?, 0x14006cc2a80?})
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230912190043-e6d96b3b8f7e/helper/schema/resource.go:967 +0x9c
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.simpleDiff({0x14000d0d560?, {0x1400143ce70?, 0x14006611c70?, 0x1a?}}, 0x0?, 0x8000106?, 0x0?, 0xffffffffffffffff?, {{{0x10997f568?, 0x1400660c9a0?}}, ...}, ...)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.66.0/pkg/tfshim/sdk-v2/provider_diff.go:101 +0x808
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.Diff({0x14000d0d560?, {0x0?, 0x0?, 0x0?}}, {0x108147c83, 0x1a}, {0x10997f3a8?, 0x1400421a720}, {0x10994eb20, 0x14006ff2f30})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.66.0/pkg/tfshim/sdk-v2/provider_diff.go:63 +0x1fc
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Diff(0x1400074b340, {0x10997ed88?, 0x14006ff26f0?}, 0x14006fcd280)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.66.0/pkg/tfbridge/provider.go:672 +0x4a4
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff.func1({0x109997a48?, 0x1400074b340?})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.7-0.20230801203955-5d215c892096/muxer.go:338 +0x3c
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.resourceMethod[...](0x140012d1130?, 0x1400651b778, 0x1400651b758?)
        /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).Diff(0x1400651b7b8?, {0x10997ed88?, 0x14006ff26f0?}, 0x1090087c0?)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.7-0.20230801203955-5d215c892096/muxer.go:337 +0x5c
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Diff_Handler.func1({0x10997ed88, 0x14006ff26f0}, {0x1096f0e20?, 0x14006fcd280})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.94.2/proto/go/provider_grpc.pb.go:575 +0x74
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x10997ed88, 0x14006ff2270}, {0x1096f0e20, 0x14006fcd280}, 0x14006fded80, 0x1400421a528)
        /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_Diff_Handler({0x1098a7980?, 0x140012d1130}, {0x10997ed88, 0x14006ff2270}, 0x14006fd3dc0, 0x14000ada4c0)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.94.2/proto/go/provider_grpc.pb.go:577 +0x12c
    google.golang.org/grpc.(*Server).processUnaryRPC(0x140004dc960, {0x109992480, 0x140059104e0}, 0x14006fecea0, 0x1400640bb60, 0x10d6b64c8, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.58.3/server.go:1374 +0xb44
    google.golang.org/grpc.(*Server).handleStream(0x140004dc960, {0x109992480, 0x140059104e0}, 0x14006fecea0, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.58.3/server.go:1751 +0x7c4
    google.golang.org/grpc.(*Server).serveStreams.func1.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.58.3/server.go:986 +0xb4
    created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 72
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.58.3/server.go:997 +0x160

  gcp:pubsub:Subscription (identity-change-detection-sub):
    error: error reading from server: EOF

Output of pulumi about

CLI
Version 3.99.0 Go Version go1.21.5 Go Compiler gc

Plugins NAME VERSION yaml unknown

Host
OS darwin Version 14.2.1 Arch arm64

This project is written in yaml

Current Stack: GeoffMillerAZ/activtrak-identity-pubsub/dev

TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::activtrak-identity-pubsub::pulumi:pulumi:Stack::activtrak-identity-pubsub-dev pulumi:providers:gcp urn:pulumi:dev::activtrak-identity-pubsub::pulumi:providers:gcp::default gcp:pubsub/topic:Topic urn:pulumi:dev::activtrak-identity-pubsub::gcp:pubsub/topic:Topic::user-topic gcp:pubsub/topic:Topic urn:pulumi:dev::activtrak-identity-pubsub::gcp:pubsub/topic:Topic::identity-change-detection-topic gcp:pubsub/subscription:Subscription urn:pulumi:dev::activtrak-identity-pubsub::gcp:pubsub/subscription:Subscription::identity-change-detection-sub

Found no pending operations associated with dev

Backend
Name pulumi.com URL https://app.pulumi.com/GeoffMillerAZ User GeoffMillerAZ Organizations GeoffMillerAZ Token type personal

No dependencies found

Pulumi locates its logs in /var/folders/39/pjbcs1t54djdg68ptpxw5q880000gn/T/ by default

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).

Frassle commented 6 months ago

cc @pulumi/providers this is probably a validation issue in gcp/tfbridge, but likely also a yaml bug here around config/property types.

VenelinMartinov commented 6 months ago

The provider bit looks like https://github.com/pulumi/pulumi-gcp/issues/1377 - it's an issue with gcp labels with boolean values.

Did you upgrade your gcp provider version to get past the issue?

t0yv0 commented 6 months ago

Curious also why pulumi about does not report the gcp version?

iwahbe commented 6 months ago

Curious also why pulumi about does not report the gcp version?

Because pulumi about derives this information from pulumi SDKs specified (requirements.txt, package.json, etc.). YAML doesn't have this.

t0yv0 commented 6 months ago

Logged request here: https://github.com/pulumi/pulumi-yaml/issues/543 thank you!

GeoffMillerAZ commented 6 months ago

I updated in the following manner:

pulumi plugin install resource gcp

[resource plugin gcp-7.5.0] installing
Downloading plugin: 67.24 MiB

And it is now working for my test case. Thanks.