Amplify-cli: An error occured during the push operation: Cannot convert undefined or null to object

Created on 3 Sep 2019  ·  12Comments  ·  Source: aws-amplify/amplify-cli

Describe the bug
Initial push works but if I make a change to schema.graphql I get An error occured during the push operation: Cannot convert undefined or null to object

To Reproduce
Steps to reproduce the behavior:

  1. amplify init
  2. amplify add api
❯ amplify add api
? Please select from one of the below mentioned services GraphQL
? Provide API name: somename
? Choose an authorization type for the API Amazon Cognito User Pool
Using service: Cognito, provided by: awscloudformation

 The current configured provider is Amazon Cognito.

 Do you want to use the default authentication and security configuration? Manual configuration
 Select the authentication/authorization services that you want to use: User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features for images or other
 content, Analytics, and more)
 Please provide a friendly name for your resource that will be used to label this category in the project: somename52d2c89852d2c898
 Please enter a name for your identity pool. somename52d2c898_identitypool_52d2c898
 Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) Yes
 Do you want to enable 3rd party authentication providers in your identity pool? No
 Please provide a name for your user pool: somename52d2c898_userpool_52d2c898
 Warning: you will not be able to edit these selections.
 How do you want users to be able to sign in? Username
 Multifactor authentication (MFA) user login options: OFF
 Email based user registration/forgot password: Enabled (Requires per-user email entry at registration)
 Please specify an email verification subject: Your verification code
 Please specify an email verification message: Your verification code is {####}
 Do you want to override the default password policy for this User Pool? No
 Warning: you will not be able to edit these selections.
 What attributes are required for signing up? (Press <space> to select, <a> to toggle all, <i> to invert selection)Email
 Specify the app's refresh token expiration period (in days): 30
 Do you want to specify the user attributes this app can read and write? No
 Do you want to enable any of the following capabilities? (Press <space> to select, <a> to toggle all, <i> to invert selection)
 Do you want to use an OAuth flow? No
? Do you want to configure Lambda Triggers for Cognito? Yes
? Which triggers do you want to enable for Cognito Pre Sign-up, Pre Token Generation
? What functionality do you want to use for Pre Sign-up Create your own module
? What functionality do you want to use for Pre Token Generation Create your own module
Succesfully added the Lambda function locally
? Do you want to edit your custom function now? No
Succesfully added the Lambda function locally
? Do you want to edit your custom function now? No
Successfully added auth resource
? Do you have an annotated GraphQL schema? No
? Do you want a guided schema creation? No
? Provide a custom type name MyType
Creating a base schema for you...
  1. amplify api add-graphql-datasource
❯ amplify api add-graphql-datasource
Using datasource: Aurora Serverless, provided by: awscloudformation
? Provide the region in which your cluster is located: us-east-1
? Select the Aurora Serverless cluster that will be used as the data source for your API: app-cluster-dev
✔ Fetched Aurora Serverless cluster.
? Select the database to use as the datasource: MY_DB
Successfully added the Aurora Serverless datasource locally

Some next steps:
"amplify push" will build all your local backend resources and provision it in the cloud
"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud


The following types do not have '@auth' enabled. Consider using @auth with @model
     - MyType
Learn more about @auth here: https://aws-amplify.github.io/docs/cli-toolchain/graphql#auth


GraphQL schema compiled successfully.

Edit your schema at /Users/somename/amplify/backend/api/somename/schema.graphql or place .graphql files in a directory at /Users/somename/amplify/backend/api/somename/schema
  1. Edit /Users/somename/amplify/backend/api/somename/schema.graphql
    I removed id: Int! from the block below since id is auto incrementing.
input CreatePostInput {
  id: Int!
  User_id: Int!
  title: String
  content: String
}
  1. amplify push

Expected behavior
Push works as expected.

Desktop (please complete the following information):

  • OS: OSX
  • amplify -v 3.0.0
graphql-transformer pending-response pending-triage

Most helpful comment

I am also running into this issue when redeploying an AppSync API via Amplify after changing the graphql schema. @MaximumCrash's workaround to do amplify init then amplify push worked for me. There's almost no error output, no stack traces or anything, so it's hard to figure out where the problem is.

All 12 comments

Do you have custom resources in your project?

@yuth, I don't think so. I was able to reproduce the error with a fresh test directory using the minimal steps above.

Was thinking this could be a possible edge case with amplify api add-graphql-datasource but really not sure. Unfortunately, this blocking development since I cannot update my schema.

@oste, I've been running into this issue as well with amplify push. (I use RDS a lot) My current solution is running amplify init, selecting your existing environment and then running your desired amplify commands. Sadly, I have to do this every time or the error persists.

This works consistently for me as a work around.

Thanks for the suggestion @MaximumCrash. That works for now. Will keep this open for now.

I am also running into this issue when redeploying an AppSync API via Amplify after changing the graphql schema. @MaximumCrash's workaround to do amplify init then amplify push worked for me. There's almost no error output, no stack traces or anything, so it's hard to figure out where the problem is.

Also having the same problem but thanks for the workaround!

@oste
I tried but was not able to reproduce the issue with the latest Amplify CLI version(3.14.0) on node v12.11.1 and node v10.16.3 (LTS).
When you got the error, what was the node version? and OSX version?

Did the error happen before the Cloudformation stacks are been created / updated? or It happens during the process of the Cloudformation updating the stacks?
Could you take a screenshot of what leads to the error on the terminal ?
If the error happens after the Cloudformation started its creation/update of the stacks, please go to the CloudFormation web console and see if you can get more information of what went wrong.

@oste
If you are using the CLI auto generated schema, input CreatePostInput should not appear in the /Users/somename/amplify/backend/api/somename/schema.graphql
(you will see input CreateOrdersInput there though, which was for the RDS datasource).

input CreatePostInput should appears under /Users/somename/amplify/backend/api/somename/build/schema.graphql
which you should not manually modify

@oste @MaximumCrash Are you'll still consistently seeing this issue with the latest version of the CLI?

@kaustavghosh06 I've moved off of using amplify in my current project, so I don't have the ability to confirm right now.

A little late to the party, but I had this issue and @MaximumCrash's solution didn't work (unfortunately). My issue was due to having Named Profiles, which for some reason ended up duplicated after initializing my amplify project.

  1. cat ~/.aws/config and cat ~/.aws/credentials
  2. Check if any were duplicated (some of the Amplify-generated ones are prepended with "profile-")
  3. Remove the duplicates
  4. Run amplify init or whatever you want

Amplify Version: 4.20.0

Was this page helpful?
0 / 5 - 0 ratings