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

'Module not found' error from JSII kernel in non-typescript languages #1904

Closed
1 of 4 tasks
nija-at opened this issue Aug 17, 2020 · 0 comments · Fixed by #1906
Closed
1 of 4 tasks

'Module not found' error from JSII kernel in non-typescript languages #1904

nija-at opened this issue Aug 17, 2020 · 0 comments · Fixed by #1906
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort module/runtime Issues affecting the `jsii-runtime` p1

Comments

@nija-at
Copy link
Contributor

nija-at commented Aug 17, 2020

🐛 Bug Report

Affected Languages

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

General Information

  • JSII Version: 1.9.0
  • Platform: OSX

What is the problem?

The following code throws the error - Module '@aws-cdk/aws-lambda' not found - with a stack trace from the kernel. This occurs exactly at the line where a Fn.conditionIf() is called and assigned to a variable.

package com.myorg;
import software.amazon.awscdk.core.App;
import software.amazon.awscdk.core.ICfnConditionExpression;
import software.amazon.awscdk.core.Fn;
import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.services.lambda.*;
import java.util.List;
import java.util.concurrent.locks.Condition;
import java.util.ArrayList;
public class HelloCdkJavaApp {
    public static void main(final String[] args) {
        final App app = new App();
        final Stack stack = new Stack(app, "mystack");
        final List<String> groups = new ArrayList<String>();
        groups.add("securitygroup1");
        final List<String> subnets = new ArrayList<String>();
        subnets.add("subnet1");
        final CfnFunction.VpcConfigProperty prop = new CfnFunction.VpcConfigProperty.Builder()
            .securityGroupIds(groups)
            .subnetIds(subnets)
            .build();
        final ICfnConditionExpression conditional = Fn.conditionIf("some condition", prop, "AWS::NoValue");
        new CfnFunction(stack, "fn", CfnFunctionProps.builder()
            .code(CfnFunction.CodeProperty.builder().zipFile("zipFile").build())
            .role("role")
            .handler("index.handler")
            .runtime("runtime")
            .vpcConfig(conditional)
            .build());
        app.synth();
    }
}

Verbose Log

https://gist.github.com/nija-at/cf1f83a3aa55894127e1766fd1fe6fba

@nija-at nija-at added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 17, 2020
@RomainMuller RomainMuller added effort/small Small work item – less than a day of effort module/runtime Issues affecting the `jsii-runtime` p1 and removed needs-triage This issue or PR still needs to be triaged. labels Aug 17, 2020
@RomainMuller RomainMuller self-assigned this Aug 17, 2020
RomainMuller added a commit that referenced this issue Aug 17, 2020
Struct proxies did not trigger loading of their parent module when
passed as a parameter, which then causes the `@jsii/kernel` type checker
to be unable to locate the struct type definition for checking pruposes,
leading to a crash.

This updatates the `JsiiSerializable` serialization process to
proactively load the relevant modules (the call is idempotent and short
circuits if the module is known to already be loaded).

Fixes #1904
@mergify mergify bot closed this as completed in #1906 Aug 19, 2020
mergify bot pushed a commit that referenced this issue Aug 19, 2020
Struct proxies did not trigger loading of their parent module when
passed as a parameter, which then causes the `@jsii/kernel` type checker
to be unable to locate the struct type definition for checking pruposes,
leading to a crash.

This updatates the `JsiiSerializable` serialization process to
proactively load the relevant modules (the call is idempotent and short
circuits if the module is known to already be loaded).

Fixes #1904



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
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. effort/small Small work item – less than a day of effort module/runtime Issues affecting the `jsii-runtime` p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants