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 821 forks source link

amplify push throws "The "path" argument must be of type string." error #7656

Closed catherine-augustine closed 3 years ago

catherine-augustine commented 3 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

12.x

Amplify CLI Version

5.1.0

What operating system are you using?

Windows

Amplify Categories

auth, function, api

Amplify Commands

push

Describe the bug

× An error occurred when pushing the resources to the cloud

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

Expected behavior

amplify push to succeed

Reproduction steps

  1. Web app running in angular, usinglambda function to fetch records from S3 bucket.
  2. Modified a lambda function.
  3. Tried to push by running amplify push and got the error.
  4. Updated the amplify, Angular and Node js to the latest versions and still the error persists.

Package.json contents


{
  "name": "app name",
  "version": "1.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4203",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.1.1",
    "@angular/common": "~12.1.1",
    "@angular/compiler": "~12.1.1",
    "@angular/core": "~12.1.1",
    "@angular/forms": "~12.1.1",
    "@angular/localize": "^12.1.1",
    "@angular/platform-browser": "~12.1.1",
    "@angular/platform-browser-dynamic": "~12.1.1",
    "@angular/router": "~12.1.1",
    "@aws-amplify/cli": "^5.1.0",
    "@aws-amplify/core": "^4.1.2",
    "@aws-amplify/storage": "^4.2.1",
    "@fortawesome/angular-fontawesome": "^0.9.0",
    "@fortawesome/fontawesome-svg-core": "1.2.35",
    "@fortawesome/free-brands-svg-icons": "5.15.3",
    "@fortawesome/free-regular-svg-icons": "5.15.3",
    "@fortawesome/free-solid-svg-icons": "5.15.3",
    "@ng-bootstrap/ng-bootstrap": "^10.0.0",
    "@ng-select/ng-select": "^7.1.0",
    "@types/prismjs": "^1.16.5",
    "@vendia/serverless-express": "^4.3.9",
    "amplify-category-function": "^2.33.0",
    "amplify-category-hosting": "^2.7.12",
    "amplify-category-storage": "^2.12.0",
    "aws-amplify": "^4.1.2",
    "aws-amplify-angular": "^6.0.4",
    "aws4": "^1.11.0",
    "bootstrap": "^5.0.2",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "lodash": "^4.17.21",
    "ngx-spinner": "^12.0.0",
    "npm": "^7.19.1",
    "prismjs": "^1.24.0",
    "rxjs": "~7.1.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.1.1",
    "@angular/cli": "~12.1.1",
    "@angular/compiler-cli": "~12.1.1",
    "@types/jasmine": "~3.7.7",
    "@types/jasminewd2": "~2.0.9",
    "@types/node": "^15.14.0",
    "codelyzer": "^6.0.2",
    "lodash": "^4.17.21",
    "ts-node": "~10.0.0",
    "tslint": "~6.1.0",
    "typescript": "^4.3.5"
  }
}

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line ```

Additional information

No response

josefaidt commented 3 years ago

Hey @catherine-augustine :wave: thanks for raising this! I was not able to reproduce in Windows on the latest release of Node 12.x and Amplify CLI 5.1.0. I have a couple of follow-up questions to better understand the context:

catherine-augustine commented 3 years ago

Are there any additional, cloudformation-related logs that show what failed to update?

// I saw the error message on the cli terminal and I am not sure if I can check somewhere else for the logs . Let me know please, I can update.

What kind of modifications were made to the Lambda?

// The lambda function was fetching records from a S3 file using a SQL query. The first time when I created it, it deployed fine. I just removed console logs and it didnt work.

Is the Lambda a part of a layer?

// I added lambda function for the api that I created using amplify add api

catherine-augustine commented 3 years ago

image I created another env and tried pushing the changes there , and I see the error in first place

josefaidt commented 3 years ago

Hey @catherine-augustine thank you for the information! May you send a ZIP file of your project's amplify directory to amplify-cli@amazon.com?

josefaidt commented 3 years ago

Hey @catherine-augustine I saw your message, do you have a storage provider you could upload to such as Google Drive?

josefaidt commented 3 years ago

Hey @catherine-augustine I received your zip file and will be taking a look at it!

josefaidt commented 3 years ago

Hey @catherine-augustine :wave: I am unable to reproduce with the steps and zip file provided. Can you post the logs from ~/.amplify/logs/amplify-cli-<issue-date>.log after attempting to push again? On Windows the .amplify/ directory is in your users profile (typically C:\Users\<your-username>\)

catherine-augustine commented 3 years ago
2021-07-26T20:10:58.375Z|info : amplify push core  
2021-07-26T20:10:58.529Z|info : amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}

I just see this, @josefaidt

josefaidt commented 3 years ago

Hey @catherine-augustine thank you for that information! May you also post the log from the day the original error happened?

Also, to get a better idea of where the error is happening, can we try adding a console.log() statement in one of the CLI's files' catch block to log the full stack trace?

The file is located at:

code "$(npm root -g)\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\push-resources.js"

And we'll want to add the console.log in the following try/catch block at line 297

catch (error) {
  if (iterativeDeploymentWasInvoked) {
      await deploymentStateManager.failDeployment();
  }
  spinner.fail('An error occurred when pushing the resources to the cloud');
+ console.log(error)
  rollbackLambdaLayers(layerResources);
  logger('run', [resourceDefinition])(error);
  throw error;
}

Afterwards, please try executing amplify push from your project again and post the stack trace.

catherine-augustine commented 3 years ago

image I don't see that at all.

 "@aws-amplify/cli": "^5.1.0",
    "@aws-amplify/core": "^4.1.2",

These are the versions in package.json. Should I update to a higher version?

Also, I dont see the logs with the error that occured first time.

josefaidt commented 3 years ago

Okay no worries that folder was in a slightly different location on my machine as well. Perhaps it is located at the following path?

$(npm root -g)\amplify-provider-awscloudformation\lib\push-resources.js
catherine-augustine commented 3 years ago

image

I added the console log. Am I missing something? I still dont see the console error . Changed the error description. I didnt see that either on the cli console.

josefaidt commented 3 years ago

@catherine-augustine can you confirm the Amplify CLI's executable path? On Windows I believe this can be found using where.exe amplify.

Also, if you're available on Discord we can set up a time for a quick chat!

catherine-augustine commented 3 years ago

I edited the function from the console and got it deployed. Though I am not able to push from IDE yet, I am good for now.

github-actions[bot] commented 2 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.