Skip to content

Better jsii-pacmak error when dependencies doesn't have an expected target platform #3403

Open
@dontirun

Description

@dontirun

🐛 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)
  • Go

General Information

  • JSII Version: 1.54.0 (build b1b977a)`
  • Platform: 5.10.60.1-microsoft-standard-WSL2

Realted to awslabs/cdk-serverless-clamscan#355
When attempting to create a .NET package of my project with the following in the .jsii using npx jsii-pacmak -v --target dotnet

  "repository": {
    "type": "git",
    "url": "https://github.com/awslabs/cdk-serverless-clamscan"
  },
  "schema": "jsii/0.10.0",
  "targets": {
    "dotnet": {
      "namespace": "cdk.serverless.clamscan",
      "packageId": "cdk.serverless.clamscan"
    },
    "js": {
      "npm": "cdk-serverless-clamscan"
    },
    "python": {
      "distName": "cdk-serverless-clamscan",
      "module": "cdk_serverless_clamscan"
    }
  },

I received the error in the Cannot read property 'namespace' of undefined. After some debugging I think the error is caused by one of the dependencies not having a dotnet target.

    "cdk-nag": {
      ...
      "targets": {
        "js": {
          "npm": "cdk-nag"
        },
        "python": {
          "distName": "cdk-nag",
          "module": "cdk_nag"
        }
      }
    },

If this is the case there should be better error messages and property checking for targets on dependencies.

Verbose Log

$ npx jsii-pacmak -v --target dotnet
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'dotnet' for cdk-serverless-clamscan
[jsii-pacmak] [WARN] Exception occurred, not cleaning up 
[jsii-pacmak] [WARN] dotnet failed
TypeError: Cannot read property 'namespace' of undefined
    at DotNetTypeResolver.resolveNamespacesDependencies (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/targets/dotnet/dotnettyperesolver.js:71:46)
    at DotNetGenerator.generate (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.js:43:27)
    at Dotnet.generateCode (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/target.js:29:28)
    at async DotnetBuilder.generateModuleCode (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/targets/dotnet.js:94:9)
    at async /home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/targets/dotnet.js:62:30
    at async Function.make (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/util.js:227:36)
    at async DotnetBuilder.buildModules (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/targets/dotnet.js:35:35)
    at async Promise.all (index 0)
    at async Object.pacmak (/home/dontirun/.npm/_npx/4ad69527ec0d2015/node_modules/jsii-pacmak/lib/index.js:61:9)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.language/dotnetRelated to .NET bindings (C#, F#, ...)module/pacmakIssues affecting the `jsii-pacmak` moduleneeds-reproductionThis issue needs reproduction.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions