aws-amplify / amplify-cli

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

amplify push broken in Linux: fails with The "path" argument must be of type string. Received undefined #6227

Closed nosachamos closed 3 years ago

nosachamos commented 3 years ago

Describe the bug Starting a simply React project with the sample Single Object api in Linux (I'm on Ubuntu) always fails when running amplify push. Not possible to push anything.

Amplify CLI Version Used both 4.40 and the latest 4.40.1-beta.0 - same results

To Reproduce To repro, run init a new react (I used a create-react-app app) with amplify init:

(base) stark@gpu-cluster:~/Work/mmr-dashboard (master)$ amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project dashboard
? Enter a name for the environment dev
? Choose your default editor: None
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path:  src
? Distribution Directory Path: build
? Build Command:  npm run-script build
? Start Command: npm run-script start

This succeeds. Then add an API:

(base) stark@gpu-cluster:~/Work/mmr-evolution-dashboard (master)$ amplify add api
? Please select from one of the below mentioned services: GraphQL
? Provide API name: dashboard
? Choose the default authorization type for the API API key
? Enter a description for the API key: API
? After how many days from now the API key should expire (1-365): 365
? Do you want to configure advanced settings for the GraphQL API No, I am done.
? Do you have an annotated GraphQL schema? No
? Choose a schema template: Single object with fields (e.g., “Todo” with ID, name, description)

This also seems to succeed.

Finally, run amplify push. This will fail with:


⠏ Updating resources in the cloud. This may take a few minutes...

...

UPDATE_COMPLETE                     amplify-dashboard-dev-132150 AWS::CloudFormation::Stack Mon Dec 21 2020 13:26:22 GMT-0600 (Central Standard Time) 
UPDATE_COMPLETE_CLEANUP_IN_PROGRESS amplify-dashboard-dev-132150 AWS::CloudFormation::Stack Mon Dec 21 2020 13:26:22 GMT-0600 (Central Standard Time) 
✖ An error occurred when pushing the resources to the cloud

The "path" argument must be of type string. Received undefined
An error occurred during the push operation: The "path" argument must be of type string. Received undefined

Expected behavior App should be pushed without errors.

Desktop (please complete the following information):

Additional context

Happens every time for me. I'm totally blocked.

kaustavghosh06 commented 3 years ago

@nosachamos Please take a look at the response to your comment here - https://github.com/aws-amplify/amplify-cli/issues/677#issuecomment-749142755

nosachamos commented 3 years ago

@kaustavghosh06 thank you! I did use version 4.40.1-beta.0 - does it include the fix you mentioned?

nosachamos commented 3 years ago

@kaustavghosh06 I did reinstall using the @beta tag as you suggested and it ended up installing the version I was using already:

(base) stark@gpu-cluster:~/Work/mmr-dashboard (master)$ amplify --version
4.40.1-beta.0

I guess the fix did not address the problem in my case. Could maybe have been checked into the wrong branch?

kaustavghosh06 commented 3 years ago

@nosachamos Are you seeing this on a new app (with init -> add api) or an existing app?

kaustavghosh06 commented 3 years ago

Also, one quick question - after specifying project info do you select for an AWS profile or manually enter AWS creds during the init step?

nosachamos commented 3 years ago

I tried on a brand new app. Started a new app with create-react-app, and then did init and added that simple sample api. Then I get it on push.

I tried filling in all optional things like key description, for example, just in case it was expecting something to have a value, but that didn't help.

I also checked the dev settings and the info inside local-env-info.json, and it looks good:

{
  "projectPath": "/home/stark/Work/mmr-evolution-dashboard",
  "defaultEditor": "none",
  "envName": "dev"
}

Let me know if you'd like me to check anything else. I'll be watching this ticket. Thanks a lot for looking into it!

kaustavghosh06 commented 3 years ago

@nosachamos What does your amplify/.config/local-aws-info.json look like? Please hide sensitive information like credentials when sharing.

kaustavghosh06 commented 3 years ago

Also, do you have the responses in your terminal for these questions when running amplify push?

? Do you want to generate code for your newly created GraphQL API Yes
? Choose the code generation language target javascript
? Enter the file name pattern of graphql queries, mutations and subscriptions src/graphql/**/*.js
? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions Yes
? Enter maximum statement depth [increase from default if your schema is deeply nested] 2
nosachamos commented 3 years ago

The amplify/.config/local-aws-info.json looks like this:

{
  "dev": {
    "configLevel": "project",
    "useProfile": true,
    "profileName": "default"
  }
}

And I answered the questions on amplify push like so:

 Do you want to update code for your updated GraphQL API Yes
? Do you want to generate GraphQL statements (queries, mutations and subscription) based on your schema types?
This will overwrite your current graphql queries, mutations and subscriptions Yes

I reran but did not get some of the questions you showed above this time (maybe because its not the firs time?). I will redo it from scratch on a clean project now and post here.

I used typescript on my previous run though, so I answered like this:

? Do you want to generate code for your newly created GraphQL API Yes
? Choose the code generation language target typescript
? Enter the file name pattern of graphql queries, mutations and subscriptions src/graphql/**/*.ts
? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions Yes
? Enter maximum statement depth [increase from default if your schema is deeply nested] 2
nosachamos commented 3 years ago

@kaustavghosh06 This time I made sure to run everything with sudo just in case, and the error is gone!

So it seems this could use a better error message but the issue was lack of permissions to do something... Should this ticket cover giving a better message? Or can it be closed?

ammarkarachi commented 3 years ago

That's great! @nosachamos I wonder which file it is, can you check ~/.amplify/logs for the latest file and see if it gives any clues to where it is failing?

kaustavghosh06 commented 3 years ago

@nosachamos You shouldn't need to run the amplify commands with sudo unless the project itself has only a sudo level permissions. For example - did you run create-react-app using sudo?

nosachamos commented 3 years ago

@kaustavghosh06 This particular time I did run create-react-app using sudo. I am not sure how I did last time, but its very possible I did as a habit. Good to know!

@ammarkarachi I checked but I can't quite tell where the path is missing there. Here is what I see in the logs:

...
2020-12-21T18:55:49.930Z|info : amplify-provider-awscloudformation.utility-functions.getIntrospectionSchema.appSyncModel.appSync.getIntrospectionSchema([{"apiId":"[***]342opyq6bdy","format":"JSON"}])
2020-12-21T18:55:50.392Z|error : amplify-provider-awscloudformation.push-resources.run([{"resourcesToBeCreated":[{"service":"AppSync","providerPlugin":"[***]rmation","output":{"authConfig":{"defaultAuthentication":{"authenticationType":"API_KEY","apiKeyConfig":{"apiKeyExpirationDays":365,"description":""}},"additionalAuthenticationProviders":[]}},"resourceName":"[***]dashboar","category":"api"}],"resourcesToBeUpdated":[],"resourcesToBeSynced":[],"resourcesToBeDeleted":[],"tagsUpdated":false,"allResources":[{"service":"AppSync","providerPlugin":"[***]rmation","output":{"authConfig":{"defaultAuthentication":{"authenticationType":"API_KEY","apiKeyConfig":{"apiKeyExpirationDays":365,"description":""}},"additionalAuthenticationProviders":[]}},"resourceName":"[***]dashboar","category":"api"}]}])
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
nosachamos commented 3 years ago

@kaustavghosh06 unfortunately on my existing project I still get that same error even when running all commands with sudo.?The logs show the same kind of error:

2020-12-21T20:15:16.259Z|info : amplify-provider-awscloudformation.utility-functions.getIntrospectionSchema.appSyncModel.appSync.getIntrospectionSchema([{"apiId":"[***]p6pbmqbreum","format":"JSON"}])
2020-12-21T20:15:16.739Z|error : amplify-provider-awscloudformation.push-resources.run([{"resourcesToBeCreated":[{"service":"AppSync","providerPlugin":"[***]rmation","output":{"authConfig":{"defaultAuthentication":{"authenticationType":"API_KEY","apiKeyConfig":{"apiKeyExpirationDays":365,"description":""}},"additionalAuthenticationProviders":[]}},"resourceName":"[***]dashboar","category":"api"}],"resourcesToBeUpdated":[],"resourcesToBeSynced":[],"resourcesToBeDeleted":[],"tagsUpdated":false,"allResources":[{"service":"AppSync","providerPlugin":"[***]rmation","output":{"authConfig":{"defaultAuthentication":{"authenticationType":"API_KEY","apiKeyConfig":{"apiKeyExpirationDays":365,"description":""}},"additionalAuthenticationProviders":[]}},"resourceName":"[***]dashboar","category":"api"}]}])
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Is there anything else I can do to help track down the issue?

In this project I ran amplify delete and started from scratch, except that I ran everything with sudo, but got the error.

nosachamos commented 3 years ago

I figured out what was wrong!

I don't know how this appened, but the generated .graphqlconfig.yml file was missing this section:

extensions:
  amplify:
    version: 3

I added it manually and now its working. Mystery solved. Now how it got like that I don't know...

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.