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

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

Open
1 of 5 tasks
dontirun opened this issue Feb 28, 2022 · 0 comments
Open
1 of 5 tasks
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...) module/pacmak Issues affecting the `jsii-pacmak` module needs-reproduction This issue needs reproduction. p1

Comments

@dontirun
Copy link

dontirun commented Feb 28, 2022

🐛 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)
@dontirun dontirun added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 28, 2022
@NGL321 NGL321 added module/pacmak Issues affecting the `jsii-pacmak` module needs-reproduction This issue needs reproduction. p1 and removed needs-triage This issue or PR still needs to be triaged. labels Mar 2, 2022
@mrgrain mrgrain added the language/dotnet Related to .NET bindings (C#, F#, ...) label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...) module/pacmak Issues affecting the `jsii-pacmak` module needs-reproduction This issue needs reproduction. p1
Projects
None yet
Development

No branches or pull requests

3 participants