Amplify-cli: amplify env pull --restore fails

Created on 23 Jun 2019  Â·  3Comments  Â·  Source: aws-amplify/amplify-cli

Describe the bug
amplify env pull --restore fails when restoring a backend environment

To Reproduce
Steps to reproduce the behavior:

  1. Create new project
  2. Add feature
  3. Push feature to deploy it
  4. Initialize new environment
  5. Add new feature (do not execute push)
  6. execute amplify env checkout baseenv --restore

Result:
Resources in base environment is deleted

~ amplify status                                                                                                                                       
Current Environment: testenv

| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | --------------- |

Error message:

✖ There was an error initializing your environment.
2019-06-23T16:17:37.338Z - error: uncaughtException: Cannot convert undefined or null to object date=Sun Jun 23 2019 09:17:37 GMT-0700 (PDT), pid=8907, uid=1070061038, gid=1896053708, cwd=/Users/dabit/temp/delete/multi-env, execPath=/Users/dabit/.nvm/versions/node/v8.12.0/bin/node, version=v8.12.0, argv=[/Users/dabit/.nvm/versions/node/v8.12.0/bin/node, /Users/dabit/.nvm/versions/node/v8.12.0/bin/amplify, env, pull, --restore], rss=144859136, heapTotal=115187712, heapUsed=92308472, external=1210049, loadavg=[5.0205078125, 5.01123046875, 4.95556640625], uptime=3910, trace=[column=null, file=null, function=Function.keys, line=null, method=keys, native=false, column=23, file=/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/index.js, function=initEnv, line=63, method=null, native=false, column=50, file=/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/src/lib/initialize-env.js, function=categoryInitializationTasks.push, line=40, method=push, native=false, column=18, file=/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js, function=null, line=16, method=null, native=false, column=null, file=null, function=null, line=null, method=null, native=false, column=7, file=internal/process/next_tick.js, function=process._tickDomainCallback, line=229, method=_tickDomainCallback, native=false], stack=[TypeError: Cannot convert undefined or null to object,     at Function.keys (<anonymous>),     at initEnv (/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/index.js:63:23),     at categoryInitializationTasks.push (/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/src/lib/initialize-env.js:40:50),     at /Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js:16:18,     at <anonymous>,     at process._tickDomainCallback (internal/process/next_tick.js:229:7)]

Expected behavior
Changes are discarded from new environment and are only left with what is in current

bug investigating multienv

Most helpful comment

Thanks @dabit3

I reproduced the error following your steps.
I'm root-causing it right now.
This is a bug specific to the api category.

All 3 comments

Thanks @dabit3,

Somehow I was not able to get the error following the steps your listed above with CLI version 1.7.5.
What is the CLI version that you are using?
I will chime you for more information.

I did see the the baseenv environment ended up with no features at amplify status, but if you execute amplify env pull, they will come back.

I just updated to 1.7.5 and was able to reproduce.

I was able to find 2 bugs. Here are the exact steps to reproduce:

  1. Bug when restoring and checkout out an environment. When this happens, the base environment has the resourced deleted and throws an error.
~ amplify init  # this is named baseenv
~ amplify add auth
~ amplify push
~ amplify env add
~ amplify add api # do not push
~ amplify env checkout baseenv --restore
  1. Bug when restoring an environment after checking it out. This works but throws an error (pasted below):
~ amplify init  # this is named baseenv
~ amplify add auth
~ amplify push
~ amplify env add
~ amplify add api # do not push
~ amplify env checkout baseenv
~ amplify env pull  --restore

Error:

✖ There was an error initializing your environment.
2019-06-23T21:38:35.133Z - error: uncaughtException: Cannot convert undefined or null to object date=Sun Jun 23 2019 14:38:35 GMT-0700 (PDT), pid=25675, uid=1070061038, gid=1896053708, cwd=/Users/dabit/temp/delete/multi-env, execPath=/Users/dabit/.nvm/versions/node/v8.12.0/bin/node, version=v8.12.0, argv=[/Users/dabit/.nvm/versions/node/v8.12.0/bin/node, /Users/dabit/.nvm/versions/node/v8.12.0/bin/amplify, env, pull, --restore], rss=229150720, heapTotal=187670528, heapUsed=143622560, external=10636252, loadavg=[2.66455078125, 2.74462890625, 2.5029296875], uptime=23177, trace=[column=null, file=null, function=Function.keys, line=null, method=keys, native=false, column=23, file=/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/index.js, function=initEnv, line=63, method=null, native=false, column=50, file=/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/src/lib/initialize-env.js, function=categoryInitializationTasks.push, line=40, method=push, native=false, column=18, file=/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js, function=null, line=16, method=null, native=false, column=null, file=null, function=null, line=null, method=null, native=false, column=7, file=internal/process/next_tick.js, function=process._tickDomainCallback, line=229, method=_tickDomainCallback, native=false], stack=[TypeError: Cannot convert undefined or null to object,     at Function.keys (<anonymous>),     at initEnv (/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/index.js:63:23),     at categoryInitializationTasks.push (/Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/src/lib/initialize-env.js:40:50),     at /Users/dabit/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js:16:18,     at <anonymous>,     at process._tickDomainCallback (internal/process/next_tick.js:229:7)]

Desktop:

  • OS: macOS High Sierra 10.13.6
  • Version: 1.7.5

    • NPM: 6.9.0

    • Node: v8.12.0

re:

I did see the the baseenv environment ended up with no features at amplify status, but if you execute amplify env pull, they will come back.

It this the intended functionality?

What’s the suggested way of discarding changes made in a new amplify environment?

Thanks @dabit3

I reproduced the error following your steps.
I'm root-causing it right now.
This is a bug specific to the api category.

Was this page helpful?
0 / 5 - 0 ratings