Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcp:cloudfunctions:Function: Type checking failed (environmentVariables) #1979

Closed
rh4ll opened this issue May 16, 2024 · 9 comments
Closed
Assignees
Labels
impact/panic This bug represents a panic or unexpected crash kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed

Comments

@rh4ll
Copy link

rh4ll commented May 16, 2024

What happened?

Updating from 6.67.0 to @pulumi/gcp > 7.10.0 (present in 7.22.0 too)
Run pulumi up on a stack, containing a pre existing cloud function using an environment variable

Get error:

warning: Type checking failed. If any of these are incorrect, please let us know by creating an issue at https://github.com/pului/pulumi-terraform-bridge/issues.
verification warning: expected object type, got [] type: Examine values at environmentVariables

NOTE: The typo in the error message. "/pului/

Example

Create a function similar to below in 6.67.0 then attempt to update to 7.22.0

new gcp.cloudfunctions.Function(
      `a-function`,
      {
        runtime: 'nodejs20',
        sourceArchiveBucket: EnterABucketNameHere.name,
        sourceArchiveObject: EnterArchiveObject.name,
        entryPoint: main,
        name: 'name',
        environmentVariables: [{ a_key: 'A value'}],
      },
    );

Get specified error with the following stack trace

 pulumi:pulumi:Stack (quill-infrastructure-production):
    panic: value has no attribute of that name
    goroutine 1332 [running]:
    github.com/zclconf/go-cty/cty.Value.GetAttr({{{0x5282960?, 0xc006ca5310?}}, {0x4231d80?, 0xc006cb8ff0?}}, {0x4990389, 0x7})
    	/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.14.2/cty/value_ops.go:808 +0x2f1
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2/internal/tf/plans/objchange.proposedNewAttributes(0xc006cb82d0, {{{0x5282960?, 0xc006ca50e0?}}, {0x4231d80?, 0xc006cb8bd0?}}, {{{0x5282960?, 0xc006ca5310?}}, {0x4231d80?, 0xc006cb8ff0?}})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/internal/tf/plans/objchange/objchange.go:289 +0x231
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2/internal/tf/plans/objchange.proposedNew(0xc006cb82a0, {{{0x5282960?, 0xc006ca50e0?}}, {0x4231d80?, 0xc006cb8bd0?}}, {{{0x5282960?, 0xc006ca5310?}}, {0x4231d80?, 0xc006cb8ff0?}})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/internal/tf/plans/objchange/objchange.go:89 +0x15b
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2/internal/tf/plans/objchange.ProposedNew(0x5282730?, {{{0x5282960?, 0xc006ca50e0?}}, {0x4231d80?, 0xc006cb8bd0?}}, {{{0x5282960?, 0xc006ca5310?}}, {0x4231d80?, 0xc006cb8ff0?}})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/internal/tf/plans/objchange/objchange.go:46 +0x139
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.proposedNew(0xc006c9e240?, {{{0x5282730?, 0xc006903b18?}}, {0x4231d80?, 0xc006c9f4d0?}}, {{{0x5282730?, 0xc006903248?}}, {0x4231d80?, 0xc006a3bef0?}})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/proposed_new.go:34 +0x156
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.simpleDiffViaPlanState({0x5281f68, 0xc006a3ac60}, 0x4231d80?, 0xc006c59380?, {{{0x5282730?, 0xc006903248?}}, {0x4231d80?, 0xc006a3bef0?}}, {0x494cc60, 0xc0050a4c00})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/provider_diff.go:176 +0xff
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.simpleDiff({0x4167bf?, {0x4231d80?, 0xc006ba9e60?, 0xc006a60b40?}}, {0x5281f68, 0xc006a3ac60}, 0x416050?, 0x0?, 0xc006ba9e60?, 0xc006a31400, ...)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/provider_diff.go:125 +0x698
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.Diff({0xc000727b00?, {0xc00042b6c0?, 0xc006ba9e60?, 0xc005289228?}}, {0x5281f68, 0xc006a3ac60}, {0x4a00eab, 0x1e}, {0x52827a0, 0xc006a20f90}, ...)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/provider_diff.go:75 +0x406
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.(*providerWithPlanResourceChangeDispatch).Diff(0xc00113bb90, {0x5281f68, 0xc006a3ac60}, {0x4a00eab, 0x1e}, {0x52827a0, 0xc006a20f90}, {0x525b6a0, 0xc006a31400}, {0x0, ...})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfshim/sdk-v2/provider2.go:690 +0x162
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Diff(0xc00002cc80, {0x5281f68?, 0xc006a3a840?}, 0xc006960880)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.82.0/pkg/tfbridge/provider.go:946 +0x935
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff.func1({0x529a9e0?, 0xc00002cc80?})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.9-0.20240227144008-2da15b3d6f6e/muxer.go:369 +0x30
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.resourceMethod[...](0xc004f61560?, 0x40, 0xc0052896c0?)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.9-0.20240227144008-2da15b3d6f6e/muxer.go:334 +0xb5
    github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff(0x0?, {0x5281f68?, 0xc006a3a840?}, 0x40?)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/x/muxer@v0.0.9-0.20240227144008-2da15b3d6f6e/muxer.go:368 +0x65
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Diff_Handler.func1({0x5281f68, 0xc006a3a840}, {0x4761f20?, 0xc006960880})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.114.0/proto/go/provider_grpc.pb.go:575 +0x72
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x5281f68, 0xc006a3a1e0}, {0x4761f20, 0xc006960880}, 0xc006a36100, 0xc006a20d80)
    	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x3d0
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Diff_Handler({0x4907300?, 0xc004f61560}, {0x5281f68, 0xc006a3a1e0}, 0xc006960800, 0xc001186700)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.114.0/proto/go/provider_grpc.pb.go:577 +0x135
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc00021ec00, {0x5281f68, 0xc006a3a150}, {0x5292300, 0xc00064f080}, 0xc006a38360, 0xc004fe88d0, 0x95d0588, 0x0)
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23
    google.golang.org/grpc.(*Server).handleStream(0xc00021ec00, {0x5292300, 0xc00064f080}, 0xc006a38360)
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016
    google.golang.org/grpc.(*Server).serveStreams.func2.1()
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
    created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 53
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x135

Output of pulumi about

original
pulumi:providers:gcp urn:pulumi:production::quill-infrastructure::pulumi:providers:gcp::default_6_67_0
new
pulumi:providers:gcp urn:pulumi:production::quill-infrastructure::pulumi:providers:gcp::default_7_22_0

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

@rh4ll rh4ll added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 16, 2024
@VenelinMartinov VenelinMartinov added the p1 A bug severe enough to be the next item assigned to an engineer label May 16, 2024
@VenelinMartinov
Copy link
Contributor

Hey @rh4ll, thank for reporting the issue and sorry you've had trouble. We'll address this as soon as possible!

@VenelinMartinov
Copy link
Contributor

@rh4ll looking at the latest GCP docs it looks like the environmentVariables input is now typed as a Map instead of a List[Map] - https://www.pulumi.com/registry/packages/gcp/api-docs/cloudfunctions/function/#environment_variables_python

Does your error go away if you edit your code to pass in a Map instead of a List[Map]?

e.g. environmentVariables: { a_key: 'A value'}, instead of environmentVariables: [{ a_key: 'A value'}],

@rh4ll
Copy link
Author

rh4ll commented May 16, 2024

No the typing of environmentVariables requires an array

@rh4ll
Copy link
Author

rh4ll commented May 16, 2024

Ah maybe not. Give me a few mins

@rh4ll
Copy link
Author

rh4ll commented May 16, 2024

Ergh yeah, that's sorted it.
Apologies for the superfluous issue, turns out I was looking at the signature for gen2 functions where it still requires an array, and had some typing over the top of the old functions

@VenelinMartinov
Copy link
Contributor

No, not superfluous at all - the panic you got is a pretty bad UX and the CLI should have emitted a nicer error message instead.

@guineveresaenger guineveresaenger removed the needs-triage Needs attention from the triage team label May 16, 2024
@t0yv0
Copy link
Member

t0yv0 commented May 17, 2024

CC @corymhall FYI. We recently introduced the type-checking pass specifically so it would provide some guidance like warning: Type checking failed about programs not meeting type expectations, in languages like JavaScript or plain Python where there is no built-in type-checking. It looks like conservatively we opted for these to be warnings rather than a fail-fast condition. Unfortunately the underlying bridge machinery produces very unpredictable errors on these mis-typed values, obscure panics are fairly normal, and I do not know of an easy way to fix this, except by tightening the type-checking pass to be fail-fast once we are confident that it will not have false positives.

Very much worth it to fix the typo obviously, thank you for spotting that.

@iwahbe
Copy link
Member

iwahbe commented May 17, 2024

I opened #1986 to track improving the error message and #1987 to convert the panics into errors.

@iwahbe iwahbe added the impact/panic This bug represents a panic or unexpected crash label May 18, 2024
@iwahbe iwahbe self-assigned this May 21, 2024
@iwahbe iwahbe added resolution/by-design This issue won't be fixed because the functionality is working as designed and removed p1 A bug severe enough to be the next item assigned to an engineer labels May 21, 2024
@iwahbe
Copy link
Member

iwahbe commented May 21, 2024

Upstream providers are allowed to panic when they get invalidly typed inputs. We are following up now for improving the UX when this happens.

@iwahbe iwahbe closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/panic This bug represents a panic or unexpected crash kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed
Projects
None yet
Development

No branches or pull requests

5 participants