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

Please add your +1 πŸ‘ to let us know you have encountered this

Status: RESOLVED

Overview:

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

Affected Versions

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 pin the jsii client libraries to 1.68.0:

Python

jsii==1.68.0

Java

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

Golang

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

C#

Amazon.JSII.Runtime==1.68.0

Solution:

TBD

Related Issues:


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 <module> 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: fsevents@2.3.2 (node_modules/aws-cdk/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œlinux”,β€œarch”:β€œx64”})

  • aws-cdk@2.40.0 added 1 package from 1 contributor in 2.842s

[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 <module> 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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 107
  • Comments: 46 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I am encountering this in v2.43.1:

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 <=2.43.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".
$ cdk --version
2.43.1 (build c1ebb85)

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")
    }
)

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))

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.

I am encountering this warning in v2.55.1.

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 <=2.43.0

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

We fixed the notice. It should not be sent anymore if you framework version is not in these ranges:

  • >=2.41.0 <=2.43.0

Please note though, it will be shown even if you’re not using apigateway. This is intentional as is NOT an error. This issue might be causing the same problem with other constructs, so its better to be aware of it.

Hi team, Just received this message. Not sure what is happening since it didn’t happen earlier today

` 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”. $ cdk --version 2.43.0 (build 487870a) `

It does however look like the notice is being sent out to unaffected versions as well. Sorry about that, feel free to ignore if your version doesn’t fall into the mentioned range.

Just a clarification, as mentioned by @zessx - the notice you’re seeing in the CLI is not an error. It’s just our way of letting you know about this important issue, that may affect your application.

You will see this as long as your framework version (aws-cdk-lib) is greater or equal to 2.41.0, even if the toolkit version is below that. You will see it even if not using APIGateway because this issue might affect other constructs as well.

As long as cdk synth is working for you, all good. Just avoid upgrading to >= 2.41.0.

Fix is in the oven.

@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

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