Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Cannot return null for non-nullable type: 'AWSDateTime' within parent" #1111

Open
2 of 14 tasks
fadone8 opened this issue Aug 27, 2024 · 5 comments
Open
2 of 14 tasks
Labels
pending-triage An issue that is pending triage transferred An issue was transferred from another Amplify Repository

Comments

@fadone8
Copy link

fadone8 commented Aug 27, 2024

Description

I am getting the following error in onUpdate when subscribed to real-time events on both onCreate and onUpdate. When an object is created, I am successfully receiving event.data in onCreate subscription but I am receiving an error in onUpdate subscription. Here is the error event in onUpdate:

I/flutter ( 3828): GraphQLResponse<Order>: {
I/flutter ( 3828):   "data": null,
I/flutter ( 3828):   "errors": [
I/flutter ( 3828):     {
I/flutter ( 3828):       "message": "Cannot return null for non-nullable type: 'AWSDateTime' within parent 'Order' (/onUpdateOrder/createdAt)",
I/flutter ( 3828):       "path": [
I/flutter ( 3828):         "onUpdateOrder",
I/flutter ( 3828):         "createdAt"
I/flutter ( 3828):       ]
I/flutter ( 3828):     },
I/flutter ( 3828):     {
I/flutter ( 3828):       "message": "Cannot return null for non-nullable type: 'AWSDateTime' within parent 'Order' (/onUpdateOrder/updatedAt)",
I/flutter ( 3828):       "path": [
I/flutter ( 3828):         "onUpdateOrder",
I/flutter ( 3828):         "updatedAt"
I/flutter ( 3828):       ]
I/flutter ( 3828):     }
I/flutter ( 3828):   ]
I/flutter ( 3828): }

Code:

void subscribeToOrderCreate() {
    final subscriptionRequest = ModelSubscriptions.onCreate(Order.classType);

    final Stream<GraphQLResponse<Order>> operation = Amplify.API.subscribe(
      subscriptionRequest,
      onEstablished: () => safePrint('Order create subscription established'),
    );

    subscription = operation.listen(
      (event) {
        safePrint(event);
      },
      onError: (Object e) =>
          safePrint('Error in order create subscription stream: $e'),
    );
  }
void subscribeToOrderUpdate() {
    final subscriptionRequest = ModelSubscriptions.onUpdate(Order.classType);

    final Stream<GraphQLResponse<Order>> operation = Amplify.API.subscribe(
      subscriptionRequest,
      onEstablished: () => safePrint('Order update subscription established'),
    );

    subscription = operation.listen(
      (event) {
        safePrint(event);
      },
      onError: (Object e) =>
          safePrint('Error in order update subscription stream: $e'),
    );
  }

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Subscribe to onCreate and onUpdate on a model.
  2. Create an object in that model.
  3. onUpdate subscription will receive the above error:

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

Flutter 3.22.1

Amplify Flutter Version

2.4.0

Deployment Method

Amplify CLI (Gen 1)

Schema

enum DubbingType {
  ORIGNAL
  REPLACED
}

enum OrderStatus {
  TRANSCRIBE
  TRANSCRIBING
  TRANSCRIBE_COMPLETED
  TRANSLATE
  TRANSLATING
  TRANSLATE_COMPLETED
  GENERATE_MERGE_AUDIO
  GENERATE_MERGE_AUDIO_COMPLETED
  PURCHASE
  COMPLETED
  FAILED
  CANCELLED
}

type Order @model @auth(rules: [{ allow: public }]) {
  id: ID!
  userId: ID
  title: String
  url: AWSURL
  status: OrderStatus
  duration: Int
  fps: Float
  orgLanguageIso: String
  newLanguageName: String
  newLanguageIso: String
  cost: Int
  orgVideoKey: String
  orgLanguageName: String
  orgSrtKey: String
  newSrtKey: String
  orgTranscriptKey: String
  newTranscriptKey: String
  orgWaveformKey: String
  newWaveformKey: String
  newAudioKey: String
  paid: Boolean
  newVideoKey: String
  dubbingType: DubbingType
  configKey: String
  retryCount: Int
  progress: Float
  failedReason: String
}

type Subscription {
  onOrderById(id: ID!): Order @aws_subscribe(mutations: ["updateOrder"])
}
  1. Why onUpdate subscription is receiving this event in the first place when an item is created only?
  2. Both the createdAt and updatedAt are helper fields and not explicitly overwritten. These fields are populated by Amplify.
@Jordan-Nelson Jordan-Nelson added the pending-triage An issue that is pending triage label Aug 27, 2024
@Jordan-Nelson
Copy link
Member

@fadone8 - Thanks for taking the time to open this issue. It is expected that the event is received on all devices including the device that creates or updates the model.

For the issue you are seeing, can you let me know if you have enabled conflict resolution so that we can reproduce this? Thanks.

@fadone8
Copy link
Author

fadone8 commented Aug 30, 2024

It error occurs only when an item is created in Amplify Studio manage content. The conflict resolution is disabled.

@Jordan-Nelson
Copy link
Member

Okay. I am going to transfer this to Amplify Studio then. It seems like the issue is that models create in Amplify Studio are not getting all the required field.

@Jordan-Nelson Jordan-Nelson added the transferred An issue was transferred from another Amplify Repository label Aug 30, 2024
@Jordan-Nelson Jordan-Nelson transferred this issue from aws-amplify/amplify-flutter Aug 30, 2024
@fistofzen
Copy link

fistofzen commented Sep 10, 2024

@Jordan-Nelson Is there any solution ? I am also getting the error when I create something from Content in studio.
Cannot return null for non-nullable type: 'AWSDateTime' within parent

@fistofzen
Copy link

Hello, so is there any solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage An issue that is pending triage transferred An issue was transferred from another Amplify Repository
Projects
None yet
Development

No branches or pull requests

3 participants