aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

‼️ NOTICE | apigateway: Unable to serialize value as `aws-cdk-lib.aws_apigateway.IModel`

Open jaspotter opened this issue 3 years ago • 30 comments

Please add your +1 👍 to let us know you have encountered this

Status: IN-PROGRESS

Overview:

Users of CDK in any language other than TS/JS cannot use values that return an instance of a deprecated class.

Affected Versions

  • v1: Any version greater or equal to 1.172.0
  • v2: Any version greater or equal to 2.41.0

Complete Error Message:

144 | jsii.errors.JavaScriptError:
145 | **@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**
146 | ├── 🛑 Failing value is an instance of aws-cdk-lib.aws_apigateway.EmptyModel
147 | │      EmptyModel { modelId: 'Empty' }
148 | ╰── 🔍 Failure reason(s):
149 | ╰─ Type 'aws-cdk-lib.aws_apigateway.EmptyModel' not found
150 | at Object.process (/tmp/tmpdm_u1x99/lib/program.js:6194:19)

Workaround:

Case by case workarounds, such as ones described here.

You could also downgrade CDK to version < 2.41.0 (for v2) and < 1.172.0 (for v1), and pin the jsii client libraries to 1.66.0:

Python

jsii==1.66.0

Java

<dependency>
  <groupId>software.amazon.jsii</groupId>
  <artifactId>jsii-runtime</artifactId>
  <version>1.66.0</version>
</dependency>

Golang

require (
	github.com/aws/jsii-runtime-go v1.66.0
)

C#

Amazon.JSII.Runtime==1.66.0

Solution:

TBD

Related Issues:

  • https://github.com/aws/jsii/issues/3742

Original report


Describe the bug

I have a CDK v2 project in python and the "cdk synth" command is now suddenly failing. Below is the error from CodeBuild log, this just suddenly started after my latest commit triggered a build of my CDK Pipeline where I was using CDK 2.39.0. I also am now seeing the synth step failing on my local dev environment as well and installing CDK 2.40.0 did not seem to resolve the error either.

2022/09/02 17:42:50 Running command cdk synth

144 | jsii.errors.JavaScriptError: 145 | @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 146 | ├── 🛑 Failing value is an instance of aws-cdk-lib.aws_apigateway.EmptyModel 147 | │ EmptyModel { modelId: 'Empty' } 148 | ╰── 🔍 Failure reason(s): 149 | ╰─ Type 'aws-cdk-lib.aws_apigateway.EmptyModel' not found 150 | at Object.process (/tmp/tmpdm_u1x99/lib/program.js:6194:19)

...

158 | The above exception was the direct cause of the following exception: 159 |   160 | Traceback (most recent call last): 161 | File "/codebuild/output/src197530525/src/app.py", line 10, in 162 | NextgenPipeline(app, "Nextgen", env=pipeline_env)

...

192 | raise JSIIError(resp.error) from JavaScriptError(resp.stack) 193 | jsii.errors.JSIIError: Of static property aws-cdk-lib.aws_apigateway.Model.EMPTY_MODEL: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel 194 | ├── 🛑 Failing value is an instance of aws-cdk-lib.aws_apigateway.EmptyModel 195 | │ EmptyModel { modelId: 'Empty' } 196 | ╰── 🔍 Failure reason(s): 197 | ╰─ Type 'aws-cdk-lib.aws_apigateway.EmptyModel' not found 198 |  

Expected Behavior

I am expecting the "cdk synth" command to complete successfully.

Current Behavior

Currently the "cdk synth" step is failing to complete. Below is the full log from CodeBuild during my pipeline execution:

[Container] 2022/09/02 17:41:50 Waiting for agent ping [Container] 2022/09/02 17:41:51 Waiting for DOWNLOAD_SOURCE [Container] 2022/09/02 17:41:51 Phase is DOWNLOAD_SOURCE [Container] 2022/09/02 17:41:51 CODEBUILD_SRC_DIR=/codebuild/output/src197530525/src [Container] 2022/09/02 17:41:51 YAML location is /codebuild/readonly/buildspec.yml [Container] 2022/09/02 17:41:51 Setting HTTP client timeout to higher timeout for S3 source [Container] 2022/09/02 17:41:51 Processing environment variables [Container] 2022/09/02 17:41:52 No runtime version selected in buildspec. [Container] 2022/09/02 17:41:54 Moving to directory /codebuild/output/src197530525/src [Container] 2022/09/02 17:41:54 Configuring ssm agent with target id: codebuild:358e2836-7acb-4c8c-9210-9bb6f58d3d69 [Container] 2022/09/02 17:41:54 Successfully updated ssm agent configuration [Container] 2022/09/02 17:41:54 Registering with agent [Container] 2022/09/02 17:41:54 Phases found in YAML: 1 [Container] 2022/09/02 17:41:54 BUILD: 4 commands [Container] 2022/09/02 17:41:54 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED [Container] 2022/09/02 17:41:54 Phase context status code: Message: [Container] 2022/09/02 17:41:54 Entering phase INSTALL [Container] 2022/09/02 17:41:54 Phase complete: INSTALL State: SUCCEEDED [Container] 2022/09/02 17:41:54 Phase context status code: Message: [Container] 2022/09/02 17:41:54 Entering phase PRE_BUILD [Container] 2022/09/02 17:41:54 Phase complete: PRE_BUILD State: SUCCEEDED [Container] 2022/09/02 17:41:54 Phase context status code: Message: [Container] 2022/09/02 17:41:54 Entering phase BUILD [Container] 2022/09/02 17:41:54 Running command npm install -g aws-cdk /usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/aws-cdk/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

[Container] 2022/09/02 17:42:09 Running command python -m pip install -r requirements.txt Collecting aws-cdk-lib==2.40.0 Downloading aws_cdk_lib-2.40.0-py3-none-any.whl (61.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.9/61.9 MB 38.0 MB/s eta 0:00:00 Collecting constructs<11.0.0,>=10.0.0 Downloading constructs-10.1.94-py3-none-any.whl (56 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.4/56.4 kB 4.2 MB/s eta 0:00:00 Collecting pytest==6.2.5 Downloading pytest-6.2.5-py3-none-any.whl (280 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 280.7/280.7 kB 28.9 MB/s eta 0:00:00 Collecting syrupy==1.7.0 Downloading syrupy-1.7.0-py3-none-any.whl (38 kB) Collecting boto3==1.20.32 Downloading boto3-1.20.32-py3-none-any.whl (131 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 131.8/131.8 kB 9.6 MB/s eta 0:00:00 Collecting aws-lambda-powertools==1.26.0 Downloading aws_lambda_powertools-1.26.0-py3-none-any.whl (173 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 173.6/173.6 kB 16.4 MB/s eta 0:00:00 Collecting requests==2.28.1 Downloading requests-2.28.1-py3-none-any.whl (62 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 4.9 MB/s eta 0:00:00 Collecting beautifulsoup4==4.11.1 Downloading beautifulsoup4-4.11.1-py3-none-any.whl (128 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 128.2/128.2 kB 12.7 MB/s eta 0:00:00 Collecting publication>=0.0.3 Downloading publication-0.0.3-py2.py3-none-any.whl (7.7 kB) Collecting jsii<2.0.0,>=1.66.0 Downloading jsii-1.67.0-py3-none-any.whl (547 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 547.4/547.4 kB 35.6 MB/s eta 0:00:00 Collecting typeguard~=2.13.3 Downloading typeguard-2.13.3-py3-none-any.whl (17 kB) Collecting pluggy<2.0,>=0.12 Downloading pluggy-1.0.0-py2.py3-none-any.whl (13 kB) Collecting py>=1.8.2 Downloading py-1.11.0-py2.py3-none-any.whl (98 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.7/98.7 kB 9.6 MB/s eta 0:00:00 Requirement already satisfied: attrs>=19.2.0 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from pytest==6.2.5->-r requirements.txt (line 3)) (21.4.0) Collecting toml Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB) Collecting packaging Downloading packaging-21.3-py3-none-any.whl (40 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 kB 13.4 MB/s eta 0:00:00 Collecting iniconfig Downloading iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB) Collecting colored<2.0.0,>=1.3.92 Downloading colored-1.4.3.tar.gz (29 kB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Collecting s3transfer<0.6.0,>=0.5.0 Downloading s3transfer-0.5.2-py3-none-any.whl (79 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.5/79.5 kB 2.9 MB/s eta 0:00:00 Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from boto3==1.20.32->-r requirements.txt (line 5)) (0.10.0) Collecting botocore<1.24.0,>=1.23.32 Downloading botocore-1.23.54-py3-none-any.whl (8.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.5/8.5 MB 93.0 MB/s eta 0:00:00 Collecting aws-xray-sdk<3.0.0,>=2.8.0 Downloading aws_xray_sdk-2.10.0-py2.py3-none-any.whl (99 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.7/99.7 kB 29.3 MB/s eta 0:00:00 Collecting fastjsonschema<3.0.0,>=2.14.5 Downloading fastjsonschema-2.16.1-py3-none-any.whl (22 kB) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from requests==2.28.1->-r requirements.txt (line 7)) (1.26.9) Requirement already satisfied: certifi>=2017.4.17 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from requests==2.28.1->-r requirements.txt (line 7)) (2022.6.15) Collecting charset-normalizer<3,>=2 Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB) Requirement already satisfied: idna<4,>=2.5 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from requests==2.28.1->-r requirements.txt (line 7)) (2.10) Collecting soupsieve>1.2 Downloading soupsieve-2.3.2.post1-py3-none-any.whl (37 kB) Collecting wrapt Downloading wrapt-1.14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (77 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.8/77.8 kB 2.4 MB/s eta 0:00:00 Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from botocore<1.24.0,>=1.23.32->boto3==1.20.32->-r requirements.txt (line 5)) (2.8.2) Requirement already satisfied: typing-extensions<5.0,>=3.7 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from jsii<2.0.0,>=1.66.0->aws-cdk-lib==2.40.0->-r requirements.txt (line 1)) (3.10.0.0) Collecting cattrs<22.2,>=1.8 Downloading cattrs-22.1.0-py3-none-any.whl (33 kB) Collecting pyparsing!=3.0.5,>=2.0.2 Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 1.3 MB/s eta 0:00:00 Collecting exceptiongroup Downloading exceptiongroup-1.0.0rc9-py3-none-any.whl (12 kB) Requirement already satisfied: six>=1.5 in /root/.pyenv/versions/3.9.12/lib/python3.9/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.24.0,>=1.23.32->boto3==1.20.32->-r requirements.txt (line 5)) (1.16.0) Building wheels for collected packages: colored Building wheel for colored (setup.py): started Building wheel for colored (setup.py): finished with status 'done' Created wheel for colored: filename=colored-1.4.3-py3-none-any.whl size=14342 sha256=6b92539979906f58ed82424ca1b92018f3ca76c7974f9757a2cf67589e284e6d Stored in directory: /root/.cache/pip/wheels/31/7b/79/7cf37e7860649bd09d359bfbbde9084a103a35eedd8f12a592 Successfully built colored Installing collected packages: publication, iniconfig, fastjsonschema, colored, wrapt, typeguard, toml, soupsieve, pyparsing, py, pluggy, exceptiongroup, charset-normalizer, requests, packaging, cattrs, botocore, beautifulsoup4, s3transfer, pytest, jsii, aws-xray-sdk, syrupy, constructs, boto3, aws-lambda-powertools, aws-cdk-lib Attempting uninstall: requests Found existing installation: requests 2.25.1 Uninstalling requests-2.25.1: Successfully uninstalled requests-2.25.1 Attempting uninstall: botocore Found existing installation: botocore 1.27.18 Uninstalling botocore-1.27.18: Successfully uninstalled botocore-1.27.18 Attempting uninstall: s3transfer Found existing installation: s3transfer 0.6.0 Uninstalling s3transfer-0.6.0: Successfully uninstalled s3transfer-0.6.0 Attempting uninstall: boto3 Found existing installation: boto3 1.24.18 Uninstalling boto3-1.24.18: Successfully uninstalled boto3-1.24.18 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. aws-sam-cli 1.52.0 requires requests==2.25.1, but you have requests 2.28.1 which is incompatible. Successfully installed aws-cdk-lib-2.40.0 aws-lambda-powertools-1.26.0 aws-xray-sdk-2.10.0 beautifulsoup4-4.11.1 boto3-1.20.32 botocore-1.23.54 cattrs-22.1.0 charset-normalizer-2.1.1 colored-1.4.3 constructs-10.1.94 exceptiongroup-1.0.0rc9 fastjsonschema-2.16.1 iniconfig-1.1.1 jsii-1.67.0 packaging-21.3 pluggy-1.0.0 publication-0.0.3 py-1.11.0 pyparsing-3.0.9 pytest-6.2.5 requests-2.28.1 s3transfer-0.5.2 soupsieve-2.3.2.post1 syrupy-1.7.0 toml-0.10.2 typeguard-2.13.3 wrapt-1.14.1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip available: 22.1.2 -> 22.2.2 [notice] To update, run: pip install --upgrade pip

[Container] 2022/09/02 17:42:50 Running command cdk synth jsii.errors.JavaScriptError: @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) at exports.Kernel._fromSandbox (/tmp/tmpdm_u1x99/lib/program.js:5837:29) at exports.Kernel.sget (/tmp/tmpdm_u1x99/lib/program.js:5413:34) at exports.KernelHost.processRequest (/tmp/tmpdm_u1x99/lib/program.js:6618:36) at exports.KernelHost.run (/tmp/tmpdm_u1x99/lib/program.js:6592:48) at Immediate._onImmediate (/tmp/tmpdm_u1x99/lib/program.js:6593:46) at processImmediate (internal/timers.js:464:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/codebuild/output/src197530525/src/app.py", line 10, in NextgenPipeline(app, "Nextgen", env=pipeline_env) File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in call inst = super().call(*args, **kwargs) File "/codebuild/output/src197530525/src/nextgen/build_pipeline/nextgen_pipeline.py", line 64, in init wave.add_stage(DeployDev(self, "Dev")) File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in call inst = super().call(*args, **kwargs) File "/codebuild/output/src197530525/src/nextgen/build_pipeline/stages/deploy_dev.py", line 50, in init cloudsearch(self) File "/codebuild/output/src197530525/src/nextgen/build_pipeline/stages/deploy_dev.py", line 90, in cloudsearch CloudSearch( File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in call inst = super().call(*args, **kwargs) File "/codebuild/output/src197530525/src/nextgen/stacks/cloudsearch.py", line 61, in init CloudSearchAPI( File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in call inst = super().call(*args, **kwargs) File "/codebuild/output/src197530525/src/nextgen/constructs/cloudsearch/cloudsearch_api.py", line 163, in init response_models={"application/json": apigateway.Model.EMPTY_MODEL}, File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/python.py", line 16, in get return self.fget.get(obj, klass)() File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/aws_cdk/aws_apigateway/init.py", line 19608, in EMPTY_MODEL return typing.cast(IModel, jsii.sget(cls, "EMPTY_MODEL")) File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_kernel/init.py", line 148, in wrapped return _recursize_dereference(kernel, fn(kernel, *args, **kwargs)) File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_kernel/init.py", line 368, in sget return self.provider.sget( File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 356, in sget return self._process.send(request, GetResponse) File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 329, in send raise JSIIError(resp.error) from JavaScriptError(resp.stack) jsii.errors.JSIIError: 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

Subprocess exited with error 1

[Container] 2022/09/02 17:42:58 Command did not exit successfully cdk synth exit status 1 [Container] 2022/09/02 17:42:58 Phase complete: BUILD State: FAILED [Container] 2022/09/02 17:42:58 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: cdk synth. Reason: exit status 1 [Container] 2022/09/02 17:42:58 Entering phase POST_BUILD [Container] 2022/09/02 17:42:58 Phase complete: POST_BUILD State: SUCCEEDED [Container] 2022/09/02 17:42:58 Phase context status code: Message: [Container] 2022/09/02 17:42:58 Expanding base directory path: cdk.out [Container] 2022/09/02 17:42:58 Assembling file list [Container] 2022/09/02 17:42:58 Expanding cdk.out [Container] 2022/09/02 17:42:58 Expanding file paths for base directory cdk.out [Container] 2022/09/02 17:42:58 Assembling file list [Container] 2022/09/02 17:42:58 Expanding */ [Container] 2022/09/02 17:42:58 Found 26 file(s) [Container] 2022/09/02 17:42:58 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED [Container] 2022/09/02 17:42:58 Phase context status code: Message:

Reproduction Steps

run the "cdk synth" command on a CDK project that is using aws-cdk-lib.aws_apigateway.Model.EMPTY_MODEL

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.40.0

Framework Version

No response

Node.js Version

16.15.0

OS

Mac OS Montery (12.4)

Language

Python

Language Version

3.10.2

Other information

No response

jaspotter avatar Sep 02 '22 18:09 jaspotter

Can you please share how you're using the empty model? It is working fine for me

peterwoodworth avatar Sep 02 '22 18:09 peterwoodworth

ditto for me + my usage:

            method_responses=[
                agw.MethodResponse(
                    status_code='204',
                    response_models={
                        'application/json': agw.Model.EMPTY_MODEL,
                    },
                    response_parameters=cors_method_response,
                ),
                agw.MethodResponse(
                    status_code='500',
                    response_models={
                        'application/json': agw.Model.EMPTY_MODEL,
                    },
                    response_parameters=cors_method_response,
                ),
            ],

image

kornicameister avatar Sep 02 '22 23:09 kornicameister

Something is really off in here, I went down to 2.35 through 2.40 and in each release I am seeing this error in CICD pipeline. That's particularly weird because I had a PR while go that was using HTTP_2_3 that was added to CloudFront around 2.37.0 and I had no errors around that EmptyModel

kornicameister avatar Sep 03 '22 00:09 kornicameister

Could you post the full reproduction code you've used @kornicameister?

peterwoodworth avatar Sep 03 '22 00:09 peterwoodworth

Not really, code is proprietary. I will try and check if I can replicate that. On the other hand: tests or synth are failing for me only in CICD. Locally synth is working and tests are green. Most likely something differs between environments. I am using python, so I will just recreate environment and see if situation from CICD happens then.

kornicameister avatar Sep 03 '22 00:09 kornicameister

Ok, I don't have a reproduction yet, I just managed to confirm that if I recreated a virtualenv (I am using python bindings) and went from 2.40.0 to 2.36.0 each time running same test and doing:

  1. npm install -g aws-cdk@...
  2. change Python's requirements.txt
  3. reinstall Python bindings

each time if has failed with:

image

so fresh environment gave me a consistent result around error.

@peterwoodworth can you try with a fresh environment too?

kornicameister avatar Sep 03 '22 11:09 kornicameister

you might find that your "software.amazon.jsii" has upgraded to 1.67.0. This seems to be the problem. I downgraded to 1.66.0 and the problem went away.

cn-cit avatar Sep 03 '22 21:09 cn-cit

@cn-cit it actually helped. @peterwoodworth is there a way to pin 1.66.0 for now?

kornicameister avatar Sep 03 '22 23:09 kornicameister

I use the cdk with java as a maven project. I just added this as a dependency in the pom. Not sure how to do it with other environments. <dependency> <groupId>software.amazon.jsii</groupId> <artifactId>jsii-runtime</artifactId> <version>1.66.0</version> </dependency>

cn-cit avatar Sep 04 '22 05:09 cn-cit

@cn-cit @kornicameister, thanks for pointing this out. Yes, it seems that jsii 1.67.0 is culprit introducing this problem. I'm able to confirm after explicitly downgrading to jsii 1.66.0 in my requirements.txt file instead of 1.67.0 local cdk synth and my code pipeline is now working.

This matches my experience on Friday Sept 2 I first experienced this when my CDK pipeline must have pulled in jsii 1.67.0 which was also released 2 days ago. 4 hours prior to 1.67.0 being released my CDK pipeline was working fine, but then started to fail after it was released.

jaspotter avatar Sep 04 '22 15:09 jaspotter

Same thing is happening with the Java version of the CDK.

Caused by: software.amazon.jsii.JsiiException: 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

Pinning the JSII version to 1.66.0 fixes the issue.

ricall avatar Sep 05 '22 00:09 ricall

Hi guys, Same issue with JAVA cdk 2.8.0. Build worked fine until friday morning, then we got this error : Caused by: software.amazon.jsii.JsiiException: Of static property aws-cdk-lib.aws_apigateway.Model.EMPTY_MODEL: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel 03-Sep-2022 02:14:48 | ├── 🛑 Failing value is an instance of aws-cdk-lib.aws_apigateway.EmptyModel 03-Sep-2022 02:14:48 | │      EmptyModel { modelId: 'Empty' }

The version of jsii.runtime upgraded from 1.66.0 to 1.67.0 by her own. How could it be possible ?

bfiorito avatar Sep 05 '22 07:09 bfiorito

For Gradle, we can use Gradle's dependency constraints

In build.gradle / build.gradle.kts:

dependencies {
    // ... other dependencies
    constraints {
        implementation("software.amazon.jsii:jsii-runtime:1.66.0") {
            because("version 1.67.0 has an issue impacting cdk")
        }
    }
}

aamielsan avatar Sep 05 '22 08:09 aamielsan

I can confirm that pinning jsii to version 1.66.0 works on local environments. But when trying to run it from codepipeline we get the same error after pinning jsii==1.66.0 in requirements.txt

nixenos avatar Sep 05 '22 11:09 nixenos

@nixenos that's odd, I have a CICD and after making a change and not even clearing a cache, tests passed + synth happened.

image

kornicameister avatar Sep 05 '22 12:09 kornicameister

Hi. I have the same issue here with Type 'aws-cdk-lib.aws_apigateway.EmptyModel' not found Downgrade the jsii version to 1.66.0 works for me as well.

For Python users it needs to be specified explicitly under requirements.txt jsii==1.66.0 just before constracts library.

przesmak avatar Sep 07 '22 08:09 przesmak

This is very strange yesterday after we set the dependency implementation("software.amazon.jsii:jsii-runtime:1.66.0") everything worked and the Gitlab CI could synth without problems and since today the synth in Gitlab CI doesn't work anymore. I don't get this.

phamngocthanhtrung avatar Sep 07 '22 13:09 phamngocthanhtrung

@phamngocthanhtrung I had the same issue this morning and had to add exclusions to my Maven pom file to make it work again. You probably have to do something simililar.

<dependency>
	<groupId>software.amazon.awscdk</groupId>
	<artifactId>aws-cdk-lib</artifactId>
	<version>${cdk.version}</version>
	<exclusions>
		<exclusion>
			<groupId>software.amazon.jsii</groupId>
			<artifactId>jsii-runtime</artifactId>
		</exclusion>
	</exclusions>
</dependency>

<dependency>
	<groupId>software.constructs</groupId>
	<artifactId>constructs</artifactId>
	<version>${constructs.version}</version>
	<exclusions>
		<exclusion>
			<groupId>software.amazon.jsii</groupId>
			<artifactId>jsii-runtime</artifactId>
		</exclusion>
	</exclusions>
</dependency>

jazeph avatar Sep 07 '22 14:09 jazeph

@nixenos that's odd, I have a CICD and after making a change and not even clearing a cache, tests passed + synth happened.

image

Yeah it was issue on my part :D, pinning to 1.66.0 works in pipelines also

nixenos avatar Sep 08 '22 07:09 nixenos

Is there a fix or upcoming fix for this other than pinning jsii==1.66.0?

Because using the latest version of aws-cdk-lib is not compatible with this version:

jsii<2.0.0,>=1.67.0 (from constructs==10.1.102->-r requirements/dev.in (line 28)) jsii<2.0.0,>=1.67.0 (from aws-cdk-lib==2.41.0->-r requirements/dev.in (line 27))

ashleydaley avatar Sep 14 '22 12:09 ashleydaley

@peterwoodworth Reproduction is now straightforward:

  1. Use apigw.Model.EMPTY_MODEL anywhere
  2. Upgrade CDK to 2.41.0

Will fail anytime because of JSII being forced to >=1.67.0

zessx avatar Sep 15 '22 09:09 zessx

Related issue: https://github.com/aws/jsii/issues/3742

zessx avatar Sep 20 '22 09:09 zessx

Actually, if you really need CDK 2.41.0+, it is possible to overcome the issue by using apigw.Model.from_model_name() instead of these broken properties:

# Replace
apigw.MethodResponse(
    status_code = "200",
    response_models = {
        "application/json": apigw.Model.EMPTY_MODEL 
    }
)

# By
apigw.MethodResponse(
    status_code = "200",
    response_models = {
        "application/json": apigw.Model.from_model_name(stack, "ResponseModelEmpty", "Empty")
    }
)

zessx avatar Sep 20 '22 15:09 zessx

Thanks everyone, we are working on a fix.

iliapolo avatar Sep 22 '22 16:09 iliapolo

I'm having this issue using the sample-app for the language python. I installed the cdk using:

npm -g install [email protected]

and set the requirements.txt with:

aws-cdk-lib==2.40.0
constructs>=10.0.0,<11.0.0
# https://github.com/aws/aws-cdk/issues/21902
jsii==1.66.0

But still receiving the notice:

NOTICES

21902   apigateway: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel

        Overview: Users of CDK in any language other than TS/JS cannot use
                  values that return an instance of a deprecated class.

        Affected versions: framework: >=2.41.0, framework: >=1.172.0

        More information at: https://github.com/aws/aws-cdk/issues/21902

I'm just following the https://cdkworkshop.com/ and would like to understand how to solve this properly if needed.

lucasOlivio avatar Sep 22 '22 19:09 lucasOlivio

I am seeing this notice at the end of deploying various cdk stacks written in Python. I'm puzzled as to why I see this even when the stack isn't using apigateway?

>cdk --version
2.43.0 (build 487870a)

jrobbins-LiveData avatar Sep 22 '22 19:09 jrobbins-LiveData

downgrade doesn't help to solve the issue

$ cdk version
2.40.0 (build 56ba2ab)

...

NOTICES

21902	apigateway: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel

	Overview: Users of CDK in any language other than TS/JS cannot use
	          values that return an instance of a deprecated class.

	Affected versions: framework: >=2.41.0, framework: >=1.172.0

	More information at: https://github.com/aws/aws-cdk/issues/21902


If you don’t want to see a notice anymore, use "cdk acknowledge <id>". For example, "cdk acknowledge 21902".

package.json

    "aws-cdk": "=2.40.0",
    "aws-cdk-lib": "=2.40.0",

dobeerman avatar Sep 22 '22 19:09 dobeerman

I'm also seeing this issue, but with 2.39.0

% cdk version
2.39.0 (build e36bfe5)
% cdk ls
...

NOTICES

21902	apigateway: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel

	Overview: Users of CDK in any language other than TS/JS cannot use
	          values that return an instance of a deprecated class.

	Affected versions: framework: >=2.41.0, framework: >=1.172.0

	More information at: https://github.com/aws/aws-cdk/issues/21902


If you don’t want to see a notice anymore, use "cdk acknowledge <id>". For example, "cdk acknowledge 21902".

package.json

"devDependencies": {
    "@types/jest": "^26.0.10",
    "@types/node": "10.17.27",
    "jest": "^26.4.2",
    "ts-jest": "^26.2.0",
    "aws-cdk": "^2.39.0",
    "ts-node": "^9.0.0",
    "typescript": "~3.9.7"
  },
  "dependencies": {
    "aws-cdk-lib": "^2.39.0",
    "cdk-codepipeline-badge-notification": "^2.0.78",
    "constructs": "^10.0.0",
    "source-map-support": "^0.5.16"
  }

sdobberstein avatar Sep 22 '22 20:09 sdobberstein

I'm also impacted by this and the workaround (downgrade) doesn't seem to work either. I've stepped down to CDK toolkit version 2.38.1 and JSII 1.66 however I'm still affected and getting the notice:

$ cdk version
2.38.1 (build a5ced21)

$ pip list |grep -Ei 'aws|jsii'
aws-cdk.aws-apigatewayv2-alpha              2.38.1a0
aws-cdk.aws-apigatewayv2-integrations-alpha 2.38.1a0
aws-cdk-lib                                 2.38.1
jsii                                        1.66.0

$ cdk ls
...

NOTICES

21902   apigateway: Unable to serialize value as aws-cdk-lib.aws_apigateway.IModel

        Overview: Users of CDK in any language other than TS/JS cannot use
                  values that return an instance of a deprecated class.

        Affected versions: framework: >=2.41.0, framework: >=1.172.0

        More information at: https://github.com/aws/aws-cdk/issues/21902

jy-metservice avatar Sep 22 '22 21:09 jy-metservice

You're both getting a notice. A warning that had been added since, waiting for the fix.
Not the error itself.

zessx avatar Sep 22 '22 21:09 zessx