Description
After 'amplify push' can not 'push' again. Subsequent pushes fail with the error 'The "path" argument must be one of type string, Buffer, or URL. Received type object'
Other commands (like 'amplify function build') also fail. Output of failure listed below.
To Reproduce
I have project with with vue client, and rest apis
brian@nova:~/Documents/whoclean/repos/broom[skip-lambda-learn]$ amplify init
Note: It is recommended to run this command from the root of your app directory
You're initializing your project with a beta version of the CLI which supports multiple environments of your project
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: skiptest
Using default provider awscloudformation
✔ Initialized provider successfully.
Initialized your environment successfully.
Your project has been successfully initialized and connected to the cloud!
#removed output for brevity
brian@nova:~/Documents/whoclean/repos/broom[skip-lambda-learn]$ amplify push
Current Environment: skiptest
| Category | Resource name | Operation | Provider plugin |
| -------- | ---------------- | --------- | ----------------- |
| Function | dbpatch | Update | awscloudformation |
| Function | ApiXbroomdev | No Change | awscloudformation |
| Function | users | No Change | awscloudformation |
| Api | ApiX | No Change | awscloudformation |
| Api | users | No Change | awscloudformation |
| Api | dbpatch | No Change | awscloudformation |
| Auth | broomtestcognito | No Change | awscloudformation |
| Hosting | S3AndCloudFront | No Change | awscloudformation |
? Are you sure you want to continue? Yes
â ¼ Updating resources in the cloud. This may take a few minutes...
UPDATE_COMPLETE apiusers AWS::CloudFormation::Stack Tue Jan 08 2019 12:11:27 GMT-
#removed output for brevity
UPDATE_COMPLETE functiondbpatch AWS::CloudFormation::Stack Tue Jan 08 2019 12:11:54 GMT-0800 (Pacific Standard Time)
✔ All resources are updated in the cloud
brian@nova:~/Documents/whoclean/repos/broom[skip-lambda-learn]$ amplify push
Current Environment: skiptest
| Category | Resource name | Operation | Provider plugin |
| -------- | ---------------- | --------- | ----------------- |
| Function | dbpatch | Update | awscloudformation |
| Function | ApiXbroomdev | No Change | awscloudformation |
| Function | users | No Change | awscloudformation |
| Api | ApiX | No Change | awscloudformation |
| Api | users | No Change | awscloudformation |
| Api | dbpatch | No Change | awscloudformation |
| Auth | broomtestcognito | No Change | awscloudformation |
| Hosting | S3AndCloudFront | No Change | awscloudformation |
? Are you sure you want to continue? Yes
The "path" argument must be one of type string, Buffer, or URL. Received type object
This if then I try to build a function:
brian@nova:~/Documents/whoclean/repos/broom[skip-lambda-learn]$ amplify function build
? Are you sure you want to continue building the resources? Yes
â ¸ Building resources. This may take a few minutes...TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object
at Object.statSync (fs.js:862:3)
at isPackageOutdated (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:69:26)
at buildResource (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:36:5)
at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:12:24)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
✖ An error occurred when building the resources.
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object
at Object.statSync (fs.js:862:3)
at isPackageOutdated (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:69:26)
at buildResource (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:36:5)
at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js:12:24)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
There was an error building the function resources
Expected behavior
Expect push and build to succeed.
Research
If I diff the trees between what works and what does not work. The only non trivial diffs are in the amplify/backend/amplify-meta.json file.
subsequent to push each resouce has a section like
"providerMetadata": {
"s3TemplateURL": "https://s3.amazonaws.com/broom-20190106133834-deployment/amplify-cfn-templates/auth/broomtestcognito-cloudformation-template.yml",
"logicalId": "authbroomtestcognito"
}
If I swap out the amplify-meta.json with the pre push file, everything works again until the next push.
Versions
brian@nova:~/Documents/whoclean/repos$ amplify --version
0.2.1-multienv.20
This happens to me if I kill amplify push with CTRL+C when it hangs, which it appears to do roughly 80% of the time for me now. The team has previously recommended running amplify env pull --restore to fix corrupted states.
Thanks for the tip! That repairs the problem.
Note that push did succeed without error.
There is a bug here that makes the whole 'function' category unusable.
Here is a synopsis of what I'm seeing.
This makes the 'api' and 'function' categories non functional
Here is the problem
The function getSourceFiles in @aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/build-resources.js returns and array of arrays in my case. an array for every subdir below AMPLIFY_PROJECT/amplify/backend/functions/FUNCTION/src.
To fix the problem at line 65.
let sourceFiles = getSourceFiles(resourceDir, 'node_modules');
if (Array.isArray(sourceFiles)) {
sourceFiles = sourceFiles.flat(1);
}
I’ve been encountering this issue too. Taking a look at the file you brought up, I can see that it was fixed in that file in November! https://github.com/aws-amplify/amplify-cli/blob/d5401ba3d9ce1fee19a921e3267160f7c57d6966/packages/amplify-provider-awscloudformation/lib/build-resources.js#L77
Can someone from the Amplify project get a CLI update that has this updated dependency in it? Also, FWIW, I’m currently using [email protected]
@mrcoles Yes, you're right. This fix was made into the master branch but not in the mnultienv branch. We're making the change to the multienv branch as well to fix this issue. Thanks for the root-cause @mrcoles
Just merged the fix for this as a part of #749. It's in the pipeline and shoud be deployed soon as a part of 0.2.1-multienv.35.
I'm having this issue n the latest cli (4.40 as well as @aws-amplify/[email protected]).
All I do is init a new project, and add a new api with the single object (Todo example) schema. Next I do amplify push and I get this:
UPDATE_COMPLETE_CLEANUP_IN_PROGRESS amplify-mmrevolutiondashboar-dev-125108 AWS::CloudFormation::Stack Mon Dec 21 2020 12:55:34 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
I reinstalled amplify-cli, no change.
I deleted all resources, started on a brand new project. Same result.
I'm on Ubuntu 20.04.
@kaustavghosh06 I guess this issue is back - does it need to be reopened?
@nosachamos We have a potential fix for this and will be a part of the next release. You can give beta a shot by using npm install -g @aws-amplify/cli@beta
Most helpful comment
Just merged the fix for this as a part of #749. It's in the pipeline and shoud be deployed soon as a part of 0.2.1-multienv.35.