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

Cannot return null for non-nullable type: \'AWSDateTime\' within parent (/onUpdateImbybe/createdAt)"

Open jaymeen-unadkat-differenz opened this issue 1 year ago • 3 comments
trafficstars

Describe the bug

I'm facing this issue when I hit the save command.

Steps To Reproduce

Steps to reproduce the behavior:
1. Try updating any value by the save command it will give you an error.

Expected behavior

Should work properly.

Amplify Framework Version

2.25.6

Amplify Categories

API

Dependency manager

Swift PM

Swift version

5.9

CLI version

12.10.1

Xcode version

XCode 15

Relevant log output

Got failed result with GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Cannot return null for non-nullable type: \'AWSDateTime\' within parent \'Imbybe\' (/onUpdateImbybe/createdAt)", locations: nil, path: Optional([Amplify.JSONValue.string("onUpdateImbybe"), Amplify.JSONValue.string("createdAt")]), extensions: nil), Amplify.GraphQLError(message: "Cannot return null for non-nullable type: \'AWSDateTime\' within parent \'Imbybe\' (/onUpdateImbybe/updatedAt)", locations: nil, path: Optional([Amplify.JSONValue.string("onUpdateImbybe"), Amplify.JSONValue.string("updatedAt")]), extensions: nil)]

Is this a regression?

Yes

Regression additional context

No response

Platforms

iOS

OS Version

14.0

Device

Simulator iPhone 11

Specific to simulators

No - Not working anywhere

Additional context

No response

Hi @jaymeen-unadkat-differenz, can you provide us with the schema that you used, redacted if needed. Alternatively, you can run

amplify diagnose --send-report

to create a zip of the amplify project which includes the schema. (https://docs.amplify.aws/swift/tools/cli/reference/diagnose/)

Can you also provide us with the code snippet that you are using to perform the save?

Usually createAt and updatedAt are system-level fields on the model, so if you had overridden them in the schema and marked them as required, that may be related to the error you're seeing. We won't know until we have your schema to analyze and reproduce the problem.

lawmicha avatar Feb 13 '24 17:02 lawmicha

@lawmicha This is the schema which we are using

type Imbybe @model @auth(rules: [{allow: public}]){
  pk: String! @primaryKey(sortKeyFields: ["sk"])
  sk: String!
  gsi1: String @index(sortKeyFields: ["gsisk1"])
  gsisk1: String
  name: String
  description: String
  imageURL: String
  ordersEmail: String
  type: String
  street: String
  city: String
  state: String
  zipCode: Int
  productCost: Int
  productCategory: String
  numberOfDrinks: Int
  publishDate: AWSDateTime
  expirationDate: AWSDateTime
  eligibleZipCodes: [Int]
  numberOfCampaigns: Int
  numberOfOffers: Int
  remainingNumberOfCampaigns: Int
  productQuantity: Int
  primaryProduct: Boolean
  startingNumberOfDrinks: Int
  remainingNumberOfDrinks: Int
  lat: Float
  lng: Float
  operatingHours: AWSJSON
  cognitoID: String
  startingNumberOfOffers: Int
  remainingNumberOfOffers: Int
  campaignStatus: String
  rating: Int
  comment: String
}

Thanks for the schema, any code snippets and logs leading up to that error?

lawmicha avatar Feb 14 '24 14:02 lawmicha

@jaymeen-unadkat-differenz If this is still an issue that you are facing, would you be able to provide more details requested in the previous comment?

harsh62 avatar Aug 27 '24 01:08 harsh62