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

Deserialization errors on component resources accepting resources as inputs when not correctly imported #157

Closed
iwahbe opened this issue Nov 17, 2023 · 7 comments
Assignees
Labels
customer/feedback Feedback from customers kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@iwahbe
Copy link
Member

iwahbe commented Nov 17, 2023

What happened?

@MMartyn was trying to create a component provider and hit this bug. When reproing (from MMartyn/pulumi-foo@2601a09), we see a deserialization failure in the generated Pulumi SDK.

Example

Given the provider described above and the example program in examples/simple/index.ts, we see this error:

Diagnostics:
  pulumi:pulumi:Stack (simple-ooh):
    error: Error: failed to register new resource second [foo:baz:Baz]: 2 UNKNOWN: failed to copy inputs for second (foo:baz:Baz): copying input "bucket": unmarshaling value: expected a s3.Bucket, got a string
        at Object.registerResource (/Users/iwahbe/Projects/pulumi-foo/sdk/nodejs/node_modules/@pulumi/runtime/resource.ts:421:27)
        at new Resource (/Users/iwahbe/Projects/pulumi-foo/sdk/nodejs/node_modules/@pulumi/resource.ts:507:13)
        at new ComponentResource (/Users/iwahbe/Projects/pulumi-foo/sdk/nodejs/node_modules/@pulumi/resource.ts:1011:9)
        at new Baz (/Users/iwahbe/Projects/pulumi-foo/sdk/nodejs/baz/baz.ts:49:9)
        at Object.<anonymous> (/Users/iwahbe/Projects/pulumi-foo/examples/simple/index.ts:9:16)
        at Module._compile (node:internal/modules/cjs/loader:1233:14)
        at Module.m._compile (/Users/iwahbe/Projects/pulumi-foo/examples/simple/node_modules/ts-node/src/index.ts:439:23)
        at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
        at Object.require.extensions.<computed> [as .ts] (/Users/iwahbe/Projects/pulumi-foo/examples/simple/node_modules/ts-node/src/index.ts:442:12)
        at Module.load (node:internal/modules/cjs/loader:1091:32)

The error is ultimately coming from the generated SDK (`baz.ts):

        super(Baz.__pulumiType, name, resourceInputs, opts, true /*remote*/);

(src)


@MMartyn Figured out that this error would go away if the line import "@pulumi/aws"; was inserted at the top of baz.ts.

Output of pulumi about

CLI          
Version      3.94.3-dev.0
Go Version   go1.21.0
Go Compiler  gc

Plugins
NAME    VERSION
aws     6.9.0
aws     5.42.0
awsx    1.0.6
docker  3.6.1
foo     0.0.1-alpha.1699031814+2601a096
nodejs  unknown

Host     
OS       darwin
Version  13.5.2
Arch     arm64

This project is written in nodejs: executable='/opt/homebrew/bin/node' version='v20.5.0'

Current Stack: pulumi/simple/ooh

Found no resources associated with ooh

Found no pending operations associated with ooh

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

Dependencies:
NAME            VERSION
@pulumi/aws     6.9.0
@pulumi/awsx    1.0.6
@pulumi/pulumi  3.94.2
@pulumi/foo     0.0.1-alpha.1699031814
@types/node     20.9.1

Pulumi locates its logs in /var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/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).

Tasks

Preview Give feedback
No tasks being tracked yet.
@iwahbe iwahbe added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 17, 2023
@justinvp
Copy link
Member

The odd thing is that baz.ts already has import * as pulumiAws from "@pulumi/aws"; at the top. Wonder how the behavior of import "@pulumi/aws"; is different.

https://github.com/MMartyn/pulumi-foo/blob/2601a0965f786bc35ba76438e03e3937efbc916c/sdk/nodejs/baz/baz.ts#L7

@MMartyn
Copy link
Contributor

MMartyn commented Nov 17, 2023

Small correction: Adding import "@pulumi/aws"; to the examples/simple/index.ts is what made it work. And I believe it is due to the difference in how the import is handled based on this FAQ

@iwahbe
Copy link
Member Author

iwahbe commented Nov 17, 2023

Interesting. Running locally, adding import "@pulumi/aws"; to examples/simple/index.ts doesn't work, but adding it to sdk/nodejs/baz/baz.ts does.

I can cleanly enable or disable the behavior after running (cd ../../sdk/nodejs && yarn build) && yarn install && pu up.

@MMartyn
Copy link
Contributor

MMartyn commented Nov 17, 2023

Alright yeah you are correct on the simple example. On my real provider adding it to the index.ts of the main stack worked. Super weird.

@justinvp
Copy link
Member

I haven't dug into this yet, but I suspect this is pulumi/pulumi#13223, in particular: pulumi/pulumi#13223 (comment)

@mikhailshilkov mikhailshilkov removed the needs-triage Needs attention from the triage team label Nov 21, 2023
@mikhailshilkov mikhailshilkov added the customer/feedback Feedback from customers label Apr 8, 2024
@mjeffryes mjeffryes modified the milestone: 0.107 Jul 24, 2024
@mjeffryes mjeffryes added the resolution/fixed This issue was fixed label Oct 25, 2024
@mjeffryes
Copy link
Member

This should be resolved with the 3.128 release of the CLI. Please open another issue if you observer a similar problem

@pulumi-bot pulumi-bot reopened this Oct 25, 2024
@pulumi-bot
Copy link

Cannot close issue:

  • does not have an assignee

Please fix these problems and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer/feedback Feedback from customers kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

6 participants