Describe the bug
I have an amplify project with an appsync graphql api that was configured through the amplify cli. I want to update my schema. In amplify/backend/api/schema.json, I've added a new field, then ran amplify api push.
Here's the output.
Are you sure you want to continue? Yes
> An error occurred when pushing the resources to the cloud
> Cannot convert undefined or null to object
To Reproduce
Steps to reproduce the behavior:
Expected behavior
After updating the schema file, I expected the amplify api push command to resolve successfully and update the schema with the new field
Additional context

Desktop (please complete the following information):
This happens also after I create custom stack in stacks folder
stacks/customstack.json :
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"S3Bucket": {
"Type": "AWS::S3::Bucket"
}
}
}
@vientang can you check if this happens to you
note : this issue doesn't happen when I update schema.graphql
Desktop
@aada Interesting, this actually might be triggering the "Cannot convert undefined or null to object" message.
scheme.graphql file left unchanged. amplify pushI'm still getting this error message. I didn't create a custom stack but somehow when I run amplify status, it shows the hosting category operation as Update. Could this be because another developer had configured this project on their machine?
@vientang I fixed the issue by adding Parameters : {} to my custom stack
I think the problem was when amplify validates cloudformation templates it passes the parameters defined in ./amplify/backend/api/{your api name}/parameters.json and that becomes invalid when there are no parameters in the template.
It would very helpful if amplif cli had verbose option
I hope this helps you
Could this be because another developer had configured this project on their machine?
my teammates had some problems when multiple developers worked on an amplify project.
let me check how did they resolve it.
this article might be helpful multi-environments
This got me a little bit further. I've added the Parameters: {} to ./amplify/backend/api/{your api name}/parameters.json.
Now, I get the message "GraphQL schema compiled successfully. Edit your schema at ... " but right after, "An error occurred when pushing the resources to the cloud Cannot convert undefined or null to object".
I'll look into the multi-environments link you've sent. Thanks!
What I ended up doing was starting over, removing all of the services and adding them back in. This time, when I initialized the project, the project-config.json file is different.
Before
"providers": [
"awscloudformation"
],
"frontend": "javascript",
Now
"frontendHandler": {
"javascript": "/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-frontend-javascript"
},
"providers": {
"awscloudformation": "/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation"
},
"projectPath": "/path/to/my/project",
I'm unsure if this has anything to do with the issue, but updating the schema works just as described in the documentation. Thanks for looking into it @aada!
I think the problem happens due to updating amplify cli. The new versions have different structure. Can you check if the creator of your project has an older version of amplfy cli?
Hey guys, could you install the latest version of the CLI and see if the issue still exists? In the newer version we don't mantain absolute paths for the plugins (and we do a auto-migration) for you as well when upgrading to the latest version of the CLI. Please take a look at this accouncement - https://aws.amazon.com/blogs/mobile/amplify-adds-support-for-multiple-environments-custom-resolvers-larger-data-models-and-iam-roles-including-mfa/
@kaustavghosh06 Sure, I鈥檒l take a look at the new cli. My current version is 1.1.2. The true test will be in on boarding another developer. Looks like the new env command would help (and making sure we鈥檙e using the same version of amplify cli).
I think this ticket can be closed. After restarting my project, I was able to successfully initialize and update the GraphQL schema. I did the update (amplify push) many times just to be sure.
@aada I鈥檓 waiting for his response but 99% sure his version is different from my previous and new version of amplify cli.
Here鈥檚 some context in case it helps. First time I initialized the project was in mid December. Roughly 3 weeks later, the other developer configured the project on his machine. We didn鈥檛 compare our folder structure then but everything was working - auth via Cognito, hosting via S3 and reading/writing to AppSync. This issue came up when I tried to update the api. The other developer did not have issues updating the api on his machine.
@vientang Closing this issue as you mentioned is not an issue for you and your team anymore. please let me know if you're still seeing this issue and we can re-open this.
I just found success in running amplify env checkout [your-environment-name]. I made sure to git commit first just to ensure nothing in progress got lost.
Also just noticed that I had a build file open in my editor (VSCode). The User.json file in this case. Might have been no factor, but I am not certain what sort of locks the editor puts on the build files that might conflict with the CLI during the compile process.
Most helpful comment
I just found success in running
amplify env checkout [your-environment-name]. I made sure togit commitfirst just to ensure nothing in progress got lost.Also just noticed that I had a
buildfile open in my editor (VSCode). The User.json file in this case. Might have been no factor, but I am not certain what sort of locks the editor puts on the build files that might conflict with the CLI during the compile process.