Describe the bug
amplify env pull --restore fails when restoring a backend environment
To Reproduce
Steps to reproduce the behavior:
amplify env checkout baseenv --restoreResult:
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
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:
~ 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
~ 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:
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.
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.