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

Causes JavaScriptError in AWS CDK api-gateway #3742

Closed
cn-cit opened this issue Sep 5, 2022 · 4 comments · Fixed by #3763
Closed

Causes JavaScriptError in AWS CDK api-gateway #3742

cn-cit opened this issue Sep 5, 2022 · 4 comments · Fixed by #3763
Assignees
Labels
bug This issue is a bug. module/kernel Issues affecting the `jsii-kernel` module p1

Comments

@cn-cit
Copy link

cn-cit commented Sep 5, 2022

Describe the bug

When using the AWS CDK api gateway Model.EMPTY_MODEL (or ERROR_MODEL) the cdk stacks cannot synthesize or deploy.

Expected Behavior

The AWS CDK will not error when using the api gateway Model.EMPTY_MODEL

Current Behavior

@jsii/kernel.SerializationError: Of static property aws-cdk-lib.aws_apigateway.Model.EMPTY_MODEL: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel
🛑 Failing value is an instance of aws-cdk-lib.aws_apigateway.EmptyModel
EmptyModel { modelId: 'Empty' }
╰── 🔍 Failure reason(s):
╰─ Type 'aws-cdk-lib.aws_apigateway.EmptyModel' not found
at Object.process (/tmp/tmpdm_u1x99/lib/program.js:6194:19)

Reproduction Steps

use a Java cdk project and include this anywhere ...
Map<String, IModel> emptyResponseModels = new HashMap<>(); emptyResponseModels.put("application/json", Model.EMPTY_MODEL);
Use 1.67.0 of this library and the error occurs.

Possible Solution

No response

Additional Information/Context

revert back to 1.66.0 to overcome the problem.

SDK version used

AWS CDK 2.37.1

Environment details (OS name and version, etc.)

Windows 10

@zessx
Copy link

zessx commented Sep 20, 2022

Now that CDK 2.41.0+ defines the jsii<2.0.0,>=1.67.0 requirement, it is no longer possible to revert JSII back.

@RomainMuller RomainMuller self-assigned this Sep 22, 2022
@RomainMuller RomainMuller added p1 module/kernel Issues affecting the `jsii-kernel` module and removed needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2022
@RomainMuller
Copy link
Contributor

Thanks for reporting. I'm able to reproduce the issue.

This is because I attempted to simplify the assembly load procedure by leveraging runtime-type-information woven in by the compiler... which may return FQNs that are actually not exported by the assembly, triggering this bug.

RomainMuller added a commit that referenced this issue Sep 22, 2022
When a jsii module returned a private class implementation of an
interface, consuming `jsii.rtti` data may return an FQN for the internal
class, which does not exist in foreign languages, leading to an error.

Revert to tagging FQNs directly instead.

Fixes #3742
RomainMuller added a commit that referenced this issue Sep 22, 2022
When a jsii module returned a private class implementation of an
interface, consuming `jsii.rtti` data may return an FQN for the internal
class, which does not exist in foreign languages, leading to an error.

Revert to tagging FQNs directly instead.

Fixes #3742
@RomainMuller
Copy link
Contributor

Interesting - the EmptyModel class does exist and get exported in the library, however it was @deprecated in V1 and is soft-removed from V2... this explains why it still has runtime type information bound to it, but does not exist in the model.

The fix I designed still would work there... The best strategy might be to have RTTI not be woven for deprecated types that will be pruned, but this might end up requiring a huge refactor... This might hence still be the best fix.

RomainMuller added a commit that referenced this issue Sep 22, 2022
When a jsii module returned a private class implementation of an interface, consuming jsii.rtti data may return an FQN for the internal class, which does not exist in foreign languages, leading to an error.

Revert to tagging FQNs directly instead.

Fixes #3742
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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. module/kernel Issues affecting the `jsii-kernel` module p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants