aws-amplify / amplify-swift

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

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

Closed jaymeen-unadkat-differenz closed 1 month ago

jaymeen-unadkat-differenz commented 9 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 9 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 9 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 9 months ago

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

harsh62 commented 2 months ago

@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?

ruisebas commented 1 month ago

Closing due to inactivity.

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.