amplify-cli: 4.50.0 error: Cannot read property 'length' of undefined
Before opening, please confirm:
- I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- I have searched for duplicate or closed issues.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
How did you install the Amplify CLI?
AWS Amplify Build
If applicable, what version of Node.js are you using?
Not sure - whatever AWS Amplify uses
Amplify CLI Version
4.50.0
What operating system are you using?
Amazon Linux I assume
Amplify Categories
api
Amplify Commands
push
Describe the bug
Just did a very simple push that triggered CI in AWS Amplify. Got the following error. This build was working fine before 4.50.0. Our amplify build is set to push with latest amplify always.
2021-04-27T17:24:54.129Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2021-04-27T17:24:54.130Z [WARNING]: ✖ There was an error initializing your environment.
2021-04-27T17:24:54.133Z [INFO]: [0mTypeError: Cannot read property 'length' of undefined[0m
[0m at /usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:121:99[0m
[0m at Array.forEach (<anonymous>)[0m
[0m at ApiGatewayAuthStack.createPoliciesFromResources (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:120:13)[0m
[0m at /usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:94:16[0m
[0m at Array.forEach (<anonymous>)[0m
[0m at /usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:84:31[0m
[0m at Array.forEach (<anonymous>)[0m
[0m at new ApiGatewayAuthStack (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:62:23)[0m
[0m at createApiGatewayAuthResources (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:205:17)[0m
[0m at Object.consolidateApiGatewayPolicies (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:201:10)[0m
[0m at Object.createEnvLevelConstructs (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/env-level-constructs.ts:22:5)[0m
[0m at runMicrotasks (<anonymous>)[0m
[0m at processTicksAndRejections (internal/process/task_queues.js:93:5)[0m
[0m at Object.run (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:97:5)[0m
2021-04-27T17:24:54.152Z [ERROR]: !!! Build failed
2021-04-27T17:24:54.152Z [ERROR]: !!! Non-Zero Exit Code detected
Expected behavior
Should just work
Reproduction steps
- I did a very simple frontend push and AWS Amplify started deploying backend and frontend. I made no backend changes. This deployment succeeded 2 hours ago before 4.50.0 was released.
GraphQL schema(s)
# Put schemas below this line
Log output
# Put your logs below this line
Additional information
I have not tested yet locally or with < 4.50.0. Will do now.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 20 (9 by maintainers)
Setting AWS Amplify to use 4.49.0 resolved the issue and backend push went through fine.
Let me know if you need any additional info or want me to try to do a backend push on my local machine with 4.50.0. Until then I’ll leave this in your hands 😃.
@cjihrig thanks that did the trick. Removed them in the
parameters.jsonand pushed as you mentioned. Thanks again @cjihrig@blairtaylor can you confirm if any of your REST API paths are missing a
policyResourceNameproperty inapi-params.json. If so, please try runningamplify api updateand then verify thepolicyResourceNames again.Thank you for reporting this. We are working on a fix. In the mean time, if you run
amplify api updateto regenerate theapi-params.jsonfile, that should fix the issue on v4.50.0.