parse-community / Parse-SDK-Flutter

The Dart/Flutter SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
575 stars 189 forks source link

The SDK will try to save object even if its child object not saved #854

Closed Nidal-Bakir closed 1 year ago

Nidal-Bakir commented 1 year ago

New Issue Checklist

Issue Description

Steps to reproduce

This will not reproduce the error. I do not know how to force the parse server to fail to save an object so the error will appear. I catch this error while writing tests for the save() function.

  1. create ParseObject planObject
  2. create ParseObject dietPlansObject
  3. set the planObject object as a child object for dietPlansObject object
  4. call save() on the container object dietPlansObject
 final planObject = ParseObject('Plans')
          ..set('PlanName', 'plan 1'); // creating this object somehow should fail, then the error will appear.

 final dietPlansObject = ParseObject("Diet_Plans");

 dietPlansObject.set('Plan1', planObject);

 await dietPlansObject.save();

Actual Outcome

The SDK will try to Serialize the dietPlansObject to save it online but it can not because the child object is not saved. so an error will be thrown while trying to Serialize the Object.

Expected Outcome

The save() function fails to save the object and returns ParseError

Environment

Parse Flutter SDK

Server

Logs

package:parse_server_sdk/src/objects/parse_base.dart 269:76 ParseBase.toPointer package:parse_server_sdk/src/utils/parse_encoder.dart 49:20 parseEncode package:parse_server_sdk/src/objects/parse_base.dart 98:20 ParseBase.toJson. dart:collection _LinkedHashMapMixin.forEach package:parse_server_sdk/src/objects/parse_base.dart 96:12 ParseBase.toJson package:parse_server_sdk/src/objects/parse_object.dart 73:39 ParseObject.create package:parse_server_sdk/src/objects/parse_object.dart 116:26 ParseObject.save ===== asynchronous gap =========================== test/src/objects/parse_object/parse_object_save_test.dart 404:26 main..

Null check operator used on a null value

Process finished with exit code 1

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

Nidal-Bakir commented 1 year ago

@mtrezza @mbfakourii

For all the issues that I have created and assigned myself to fix them. I have fixed them and I have written the test for all of them.

I will open new PRs to fix all of them once we are done with the transition to one package. #852

mtrezza commented 1 year ago

@Nidal-Bakir Reading this I understand now why you assigned yourself to issues. We don't use the assignment feature because it may deter others from picking up an issue that is assigned. You could keep a private list of issues you're planning to work on instead.

Nidal-Bakir commented 1 year ago

Got it, thanks