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]: TypeError: Cannot read property 'length' of undefined
                                     at /usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:121:99
                                     at Array.forEach (<anonymous>)
                                     at ApiGatewayAuthStack.createPoliciesFromResources (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:120:13)
                                     at /usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:94:16
                                     at Array.forEach (<anonymous>)
                                     at /usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:84:31
                                     at Array.forEach (<anonymous>)
                                     at new ApiGatewayAuthStack (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:62:23)
                                     at createApiGatewayAuthResources (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:205:17)
                                     at Object.consolidateApiGatewayPolicies (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/consolidate-apigw-policies.ts:201:10)
                                     at Object.createEnvLevelConstructs (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/utils/env-level-constructs.ts:22:5)
                                     at runMicrotasks (<anonymous>)
                                     at processTicksAndRejections (internal/process/task_queues.js:93:5)
                                     at Object.run (/usr/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:97:5)
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

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

Commits related to this issue

Most upvoted comments

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.json and pushed as you mentioned. Thanks again @cjihrig

@blairtaylor can you confirm if any of your REST API paths are missing a policyResourceName property in api-params.json. If so, please try running amplify api update and then verify the policyResourceNames again.

Thank you for reporting this. We are working on a fix. In the mean time, if you run amplify api update to regenerate the api-params.json file, that should fix the issue on v4.50.0.