amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

amplify codegen add gives error: 'The "path" argument must be of type string'

Open MiMo42 opened this issue 7 years ago • 10 comments

Describe the bug Error when adding an existing API to codegen.

amplify codegen add --apiId XXXMyApiIdXXXX

adds "api" section to amplify-meta.json files but then terminates with error:

$ amplify codegen add --apiId XXXXXXX
✔ Getting API details
✖ Getting API details
The "path" argument must be of type string. Received type undefined

Trying to get it up and running using statements command i got a callstack:

/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/index.js:13
    throw up;
    ^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.join (path.js:1155:7)
    at projects.forEach (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-codegen/src/commands/statements.js:19:31)
    at Array.forEach (<anonymous>)
    at Object.generateStatements (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-codegen/src/commands/statements.js:18:12)
    at Command.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-codegen/commands/codegen/statements.js:11:21)
    at Runtime.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:90:58)
    at step (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:32:23)
    at Object.next (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:13:53)
    at /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/runtime/run.js:7:71 

To Reproduce Steps to reproduce the behavior:

  1. A project with no API managed by CFN
  2. type $ amplify codegen add --apiId XXXXXX to add an API that has been created with AppSync console before.

Expected behavior The command should successfully add the external API.

Desktop (please complete the following information):

  • OS: macOS
  • Amplify CLI 1.1.7

MiMo42 avatar Mar 12 '19 12:03 MiMo42

Just had similar problem. Solved it by adding projectPath attribute in <project_root>/amplify/.config/local-env-info.json with a valid path, worked both absolute and relative paths for me.

kochetkovIT avatar Mar 17 '19 14:03 kochetkovIT

I am not using environments yet. Automatic migration did not create the local-env-info.json. I added the file manually and set projectPath like @kochetkovIT suggested. Now codegen works for me again.

The automatic migration should have created the file though...

MiMo42 avatar Mar 18 '19 13:03 MiMo42

@MiMo42 Automatic migration should've ideally created the local-env-info.json file. Did you mirate from @multinev version of the CLI or master version of the CLI?

kaustavghosh06 avatar Mar 18 '19 22:03 kaustavghosh06

@kaustavghosh06 I migrated from a pre multienv era project using one of the first Amplify CLI releases supporting multienv (I am not sure which version it actually was). I did choose the migration not to create environments during the migration process when being asked for it. No betas involved. CLIs have been installed by npm install -g @aws-amplify/cli

MiMo42 avatar Mar 20 '19 06:03 MiMo42

@MiMo42 The CLI should've created the local-env-info file with the projecPath and I tried reproducing this but couldn't. Were there any speific errors during the migration or was rhe migration successful?

@kochetkovIT Would like to know about your experience as well so that I can reproduce this.

kaustavghosh06 avatar Mar 22 '19 21:03 kaustavghosh06

No errors during migration. It was successful. Migration has been performed with CLI v1.1.4

MiMo42 avatar Mar 25 '19 15:03 MiMo42

@MiMo42 We weren't able to reproduce this with the latest version of the CLI. Please feel free to re-open if you see similar behavior with any of your other projects. Would like to see your pre-migration project structure if possible in case of this behavior.

kaustavghosh06 avatar Apr 03 '19 05:04 kaustavghosh06

I am also facing this issue. I am unable to find a directory known as .config in my project folder either. Any solutions?

gvb26 avatar Apr 22 '19 22:04 gvb26

@gvb26 did you see any errors when you ran amplify commands? What was the version of last CLI you had run amplify successfully? What version do you have installed currently?

yuth avatar Apr 22 '19 23:04 yuth

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.

github-actions[bot] avatar May 27 '21 11:05 github-actions[bot]