aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
433 stars 192 forks source link

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

Open jaymeen-unadkat-differenz opened 4 months ago

jaymeen-unadkat-differenz commented 4 months ago

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

lawmicha commented 4 months ago

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.

jaymeen-unadkat-differenz commented 4 months ago

@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
}
lawmicha commented 4 months ago

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