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

Cannot convert undefined or null to object at @pulumi/runtime/closure/codePaths.ts:250:34 #16076

Open
bcheidemann-kmbal opened this issue Apr 27, 2024 · 2 comments
Labels
area/sdks Pulumi language SDKs kind/bug Some behavior is incorrect or out of spec language/javascript

Comments

@bcheidemann-kmbal
Copy link

What happened?

I was trying to run the default boilerplate generated by pulumi new serverless-aws-typescript and was faced with the following error:

$ pulumi up
Previewing update ([REDACTED])

View in Browser (Ctrl+O): https://app.pulumi.com/[REDACTED]/previews/57a4758b-7849-41ce-bdf2-bb4e349ade9c

     Type                 Name                Plan     Info
     pulumi:pulumi:Stack  [REDACTED]                   1 error; 2 messages

Diagnostics:
  pulumi:pulumi:Stack ([REDACTED]):
    (node:33492) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)

    error: Running program '[REDACTED]/packages/infrastructure/' failed with an unhandled exception:
    <ref *1> TypeError: Cannot convert undefined or null to object
        at Function.keys (<anonymous>)
        at [REDACTED]/node_modules/@pulumi/runtime/closure/codePaths.ts:250:34
        at Generator.next (<anonymous>)
        at [REDACTED]/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:21:71
        at new Promise (<anonymous>)
        at __awaiter ([REDACTED]/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:17:12)
        at allFoldersForPackages ([REDACTED]/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:166:12)
        at [REDACTED]/node_modules/@pulumi/runtime/closure/codePaths.ts:118:37
        at Generator.next (<anonymous>)
        at [REDACTED]/node_modules/@pulumi/pulumi/runtime/closure/codePaths.js:21:71 {
      promise: Promise { <rejected> [Circular *1] }
    }


npm ERR! Lifecycle script `dev` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: [REDACTED] 
npm ERR!   at location: [REDACTED]/packages/infrastructure

Example

Here are the steps I followed:

  1. Create an NPM workspace
  2. Create a workspace project at packages/infrastructure
  3. Run pulumi new serverless-aws-typescript
  4. Move dependencies from packages/infrastructure/package.json to the root package.json
  5. Run pulumi up in packages/infrastructure

Output of pulumi about

$ pulumi about
CLI          
Version      3.104.2
Go Version   go1.21.6
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host     
OS       darwin
Version  13.6.6
Arch     arm64

This project is written in nodejs: executable='/Users/benheidemann/.nvm/versions/node/v22.0.0/bin/node' version='v22.0.0'

Current Stack: kmbal/kmbal-mono/staging

TYPE                                               URN
pulumi:pulumi:Stack                                urn:pulumi:staging::kmbal-mono::pulumi:pulumi:Stack::kmbal-mono-staging
pulumi:providers:aws                               urn:pulumi:staging::kmbal-mono::pulumi:providers:aws::default_6_18_2
aws:iam/role:Role                                  urn:pulumi:staging::kmbal-mono::aws:iam/role:Role::fn
aws:lambda/function:Function                       urn:pulumi:staging::kmbal-mono::aws:lambda/function:Function::fn
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-019020e7
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-7cd09230
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-e1a3786d
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-1b4caae3
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-74d12784
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-d32a66fa
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-4aaabb8e
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-b5aeb6b6
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws:iam/rolePolicyAttachment:RolePolicyAttachment::fn-a1de8170
pulumi:providers:aws-apigateway                    urn:pulumi:staging::kmbal-mono::pulumi:providers:aws-apigateway::default_2_1_1
pulumi:providers:pulumi                            urn:pulumi:staging::kmbal-mono::pulumi:providers:pulumi::default
aws-apigateway:index:RestAPI                       urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI::api
pulumi:providers:aws                               urn:pulumi:staging::kmbal-mono::pulumi:providers:aws::default_6_0_4
aws:iam/role:Role                                  urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:iam/role:Role::api4c238266
aws:s3/bucket:Bucket                               urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:s3/bucket:Bucket::api
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:iam/rolePolicyAttachment:RolePolicyAttachment::api4c238266
aws:apigateway/restApi:RestApi                     urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:apigateway/restApi:RestApi::api
aws:s3/bucketObject:BucketObject                   urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:s3/bucketObject:BucketObject::api4c238266/index.html
aws:apigateway/deployment:Deployment               urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:apigateway/deployment:Deployment::api
aws:lambda/permission:Permission                   urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:lambda/permission:Permission::api-e7f981a5
aws:apigateway/stage:Stage                         urn:pulumi:staging::kmbal-mono::aws-apigateway:index:RestAPI$aws:apigateway/stage:Stage::api


Found no pending operations associated with kmbal/staging

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/bcheidemann-kmbal
User           bcheidemann-kmbal
Organizations  bcheidemann-kmbal, kmbal
Token type     personal

Pulumi locates its logs in /var/folders/qj/tm_rd4fj0pz80xsbrs3y0zvm0000gn/T/ by default
warning: Failed to get information about the Pulumi program's dependencies: could not find either /Users/benheidemann/repos/kmbal-monorepo/packages/infrastructure/yarn.lock or /Users/benheidemann/repos/kmbal-monorepo/packages/infrastructure/package-lock.json

Additional context

This issue seems to have been introduced in @pulumi/pulumi version 3.108.0 (version 3.107.0 works as expected).

Here is the root package.json from my workspace:

{
  "name": "[REDACTED]",
  "scripts": {},
  "workspaces": ["packages/*"],
  "dependencies": {
    "@pulumi/aws": "^6.0.0",
    "@pulumi/aws-apigateway": "^2.0.0",
    "@pulumi/awsx": "^2.0.2",
    "@pulumi/pulumi": "^3.113.0",
    "typescript": "^5.0.0"
  },
  "devDependencies": {
    "@types/folder-hash": "^4.0.4",
    "@types/node": "^18",
    "dotenv-cli": "^7.3.0",
    "folder-hash": "^4.0.4"
  }
}

And here is a working version:

{
  "name": "kmbal-monorepo",
  "scripts": {},
  "workspaces": ["packages/*"],
  "dependencies": {
    "@pulumi/aws": "6.18.2",
    "@pulumi/aws-apigateway": "2.1.1",
    "@pulumi/awsx": "2.4.0",
    "@pulumi/pulumi": "3.107.0",
    "typescript": "5.4.5"
  },
  "devDependencies": {
    "@types/folder-hash": "^4.0.4",
    "@types/node": "^18",
    "dotenv-cli": "^7.3.0",
    "folder-hash": "^4.0.4"
  }
}

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

@bcheidemann-kmbal bcheidemann-kmbal added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Apr 27, 2024
@Frassle
Copy link
Member

Frassle commented Apr 27, 2024

There's been quite a lot of work done around closure serialisation recently. I'd recommend updating to 3.114 and seeing if that helps, and if not what error (and stack trace) you get back from that.

@justinvp justinvp added area/sdks Pulumi language SDKs language/javascript and removed needs-triage Needs attention from the triage team labels May 1, 2024
@lukehoban
Copy link
Member

Move dependencies from packages/infrastructure/package.json to the root package.json

@bcheidemann-kmbal Curious to understand exactly what you mean by this. This isn't the "normal" way to use NPM Workspsace AFAIU. Instead, the dependencies stay in the place they are needed, but then packages are accumulated into root workspace and linked from there.

I expect you actually do want to keep the dependencies in the child project?

As a workaround, in case you do want this structure, you can also just add a "dependencies": {} entry to the child project.

That said, I do agree that we shouldn't panic in the case that you structure your package like this (or if for some other reason you legitimately don't have a dependencies section in your package.json).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdks Pulumi language SDKs kind/bug Some behavior is incorrect or out of spec language/javascript
Projects
None yet
Development

No branches or pull requests

4 participants