aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.81k stars 820 forks source link

Error Migrating #1384

Closed simsinght closed 5 years ago

simsinght commented 5 years ago

Describe the bug After upgrading the cli to the most recent version, I ran amplify in my project root because I wanted to use amplify to set up multiple environments. It prompted me to migrate the project, and asking me to reconfirm. At this point the program says There was an error migrating your project, and dumps a whole lot of info, none of which makes sense.

The error occurs at migrate-project.js:93:47

EDIT AFTER A DEEPER DIVER

Ok so I went through the error, and went to the location, and added a print statement. That giant dump at the bottom of this is actually what's being passed into the migrate method -- it's projectPath, and when path.join(projectPath, 'amplify', 'backend', category, resourceName) it crashes since path.join expects [String] as an argument, and projectPath is an object.

Not sure how this error is coming up. Will update if I figure out how to fix.

To Reproduce Steps to reproduce the behavior:

  1. Start at root of pre-multienv project
  2. run amplify

Expected behavior Project is migrated, and can work with multienv.

Desktop (please complete the following information):

Additional context The start of the error dump:

- Migrating your projectCould not run migration for storage: ServerlessProjects
× There was an error migrating your project.
migration operations are rolledback.
2019-05-03T01:24:06.864Z - error: uncaughtException: Path must be a string. Received Toolbox {
 . 
 . 
 . 
}
at assertPath (path.js:28:11),     
at Object.join (path.js:489:7),     
at migrate (C:\Users\ss108560\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-storage\provider-utils\awscloudformation\service-walkthroughs\dynamoDb-walkthrough.js:394:32),     
at Object.migrateResource (C:\Users\ss108560\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-storage\provider-utils\awscloudformation\index.js:44:10),     
at Object.keys.forEach (C:\Users\ss108560\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-storage\index.js:30:61),
at Array.forEach (<anonymous>),     
at Object.keys.forEach (C:\Users\ss108560\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-category-storage\index.js:26:42),     
at Array.forEach (<anonymous>),     
at migrate (C:\Users\ss108560\AppData\Roaming\npm\node_modules\@awsamplify\cli\node_modules\amplify-category-storage\index.js:24:28),     
at Array.categoryMigrationTasks.push (C:\Users\ss108560\AppData\Roaming\npm\node_modules\@aws-amplify\cli\src\lib\migrate-project.js:93:47)

The error dump I've now realized is the context object being incorrectly passed in. I've cleaned it up a bit. It was not this nice

simsinght commented 5 years ago

In the context of @aws-amplify\cli\node_modules\amplify-category-storage\provider-utils\awscloudformation

migrate function header in service-walkthroughs\dynamoDb-walkthrough.js:

function migrate(projectPath, resourceName)

migrate function call in index.js

migrate(context, projectPath, resourceName);
yuth commented 5 years ago

@simsinght do you remember what was the version of Amplify CLI before the upgrade?

Also could you list the categories that had configured before the migration

simsinght commented 5 years ago

The bug was just what I've listed above. I removed context as an argument and the rest went swimmingly.

I'll continue testing in case something has gone awry.

And no unfortunately I don't remember the CLI before the upgrade. I do know that it didn't have env command (the whole reason why I upgraded).

Can I create a pull request for removing the context bug? Kind of excited for my first real contribution to a big project :D

simsinght commented 5 years ago

The categories I had:

Current Environment: NONE

Category Resource name Operation Provider plugin
Hosting S3AndCloudFront No Change awscloudformation
Auth cognitoaad432e7 No Change awscloudformation
Storage ServerlessProjects No Change awscloudformation
Function ServerlessPortal No Change awscloudformation
Api ServerlessPortal No Change awscloudformation

Hosting endpoint: http://...

simsinght commented 5 years ago

Is there a document listing the major releases of the cli?

I had some trouble with the migration, and I'm just trying to configure the older deployment. But the new CLI keeps throwing errors. I just want to revert the cli to pre-multi-env

yuth commented 5 years ago

@simsinght Amplify CLIs changelog might have what you're looking for.

If you want pre multienv support, they should be version number less than 0.2.0

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.