aws / jsii

jsii allows code in any language to naturally interact with JavaScript classes. It is the technology that enables the AWS Cloud Development Kit to deliver polyglot libraries from a single codebase!
https://aws.github.io/jsii
Apache License 2.0
2.66k stars 247 forks source link

cdk IAspect generates: TypeError: Cannot read properties of undefined (reading 'getJsDocTags') #4569

Closed TheFlexican closed 4 months ago

TheFlexican commented 4 months ago

Describe the bug

This code generates: error JSII9997: Unknown error: Cannot read properties of undefined (reading 'getJsDocTags') -- TypeError: Cannot read properties of undefined (reading 'getJsDocTags')

I've created a projen project for aws cdk constructs, and this IAspect is part of my S3 construct, when I run npx projen build, the error is generated

export class PolicyAspect implements cdk.IAspect {
    /**
     * Visit each node in the construct tree.
     * @param node The construct node to visit.
     */
    visit(node: IConstruct): void {
      if (node instanceof cdk.aws_s3.Bucket) {
        node.addToResourcePolicy(
          new cdk.aws_iam.PolicyStatement({
            sid: 'PolicyAspectStatement',
            actions: ['s3:*'],
            effect: cdk.aws_iam.Effect.DENY,
            principals: [new cdk.aws_iam.AnyPrincipal()],
            conditions: {
              BoolIfExists: {
                'aws:PrincipalIsAWSService': 'false',
              },
              'ForAllValues:StringNotLike': {
                'aws:PrincipalOrgPath': 'ORG PATHS',
              },
            },
            resources: ["*"],
          }),
        );
      }
    }
  }

Expected Behavior

successful run.

Current Behavior

error JSII9997: Unknown error: Cannot read properties of undefined (reading 'getJsDocTags') -- TypeError: Cannot read properties of undefined (reading 'getJsDocTags') at _hasInternalJsDocTag (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/assembler.js:1863:19) at Assembler._isPrivateOrInternal (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/assembler.js:1108:37) at Assembler._visitClass (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/assembler.js:868:33) at Assembler._visitNode (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/assembler.js:664:29) at Assembler.emit (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/assembler.js:130:26) at Compiler.consumeProgram (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/compiler.js:178:40) at Compiler.buildOnce (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/compiler.js:160:21) at Compiler.emit (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/compiler.js:55:21) at Object.handler (/home/test/Projects/constructs/node_modules/.pnpm/jsii@5.4.26/node_modules/jsii/lib/main.js:146:75) at /home/test/Projects/constructs/node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/index.cjs:1:8993

Reproduction Steps

Import this into any cdk project and run jsii on the project

Possible Solution

No response

Additional Information/Context

cdkVersion: '2.149.0' siiVersion: '~5.4.0'

SDK version used

2.149.0

Environment details (OS name and version, etc.)

Ubuntu running on WSL

github-actions[bot] commented 4 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

TheFlexican commented 4 months ago

Think something is wrong on my end, need to sort that out.