Start a new topic

Relational Data - Invalid type in JSON write (KCSKinveyRef)

I am new to Kinvey but I am experiencing difficulties using Relational Data

- I am using KinveyKit-1.40.4

- I am following the steps outlined in

- I am using KCSLinkedAppdataStore

- I have confirmed that both entities are configured correctly and save individually but when I attempt to update them with a relationship (single or multiple) I get an exception.

'NSInvalidArgumentException', reason: 'Invalid type in JSON write (KCSKinveyRef)'

Can anyone suggest a possible solution? I am missing an important step?

2 people have this question

I just wanted to follow up on this guys... We are looking to address this issue in the present sprint, it slipped from the last one due to competing priorities.   I'm going to see if I can get this prioritized to be released this week if at all possible.   


2 people like this

Hello Everyone,

The problem that Damien is referencing in his last update on March 28, 2016, has been fixed in the iOS SDK release 1.40.6 which can be found and downloaded at the following URL.

This fix is identified in the download notice as:

"Bug fix: Handling arrays for Relational Data using KCSLinkedAppdataStore"

Please let us know if you have any difficulties with this update.


Billy Gee

2 people like this

Hi , each time when I use KCSLinkedAppdataStore in  release 1.40.6  I get next exception 

2016-04-07 11:21:19.515 BooksAround[2315:685126] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSDictionaryM: 0x16193b9d0> was mutated while being enumerated.'

*** First throw call stack:

(0x18146ee38 0x180ad3f80 0x18146e86c 0x100431cf4 0x100431f2c 0x10043204c 0x1003c9ea0 0x1003c9fd0 0x1003b8e00 0x1003b99f8 0x1003b9840 0x1003ba3c4 0x1003bb534 0x100438754 0x181e2a904 0x10057da3c 0x10058a554 0x10058172c 0x10058c66c 0x10058c364 0x1810d1470 0x1810d1020)

libc++abi.dylib: terminating with uncaught exception of type NSException

In 1.40.5 it worked ok

Best Regards


Thank you very much, Billy and Damien. I look forward to trying it out!

Wood Wayfarer:

That might have been a bug in version 1.40.6 of the SDK, rather than directly related to the relational data issue. I also received that error when making queries after upgrading from 1.40.5 to 1.40.6. Upgrading to 1.40.7 solved the problem.

See this thread:

Hello Everyone,

Mr LoPinto is absolutely correct. There is a bug with the iOS SDK v1.40.6. When it was discovered, the fix was made immediately and iOS SDK v1.40.7 was created and made available for download last night. I have submitted a request to remove 1.40.6 from the iOS download site but that said, 1.40.7 is the version everyone should use.


Billy Gee


I have been having problems saving a little more complex relational data so I created some simple tests to pinpoint the problem.  My root object A contains a collection of objects B, object B contains a collection of objects C and object C contains a collection of objects D. In my first test,  I only have one object in every of those collections - A contains one object B, B Contains only one object C, and C contains only one object D - save works fine. However, if the tree has two branches - A contains two B's and the rest is the same - save does not work. It gives no error but never goes to the completion block. Query works fine though.

Then I removed one of the two D objects so that one branch ends with C and the other with D  and save worked. In the KinveyDb, the Kinveyref entry of the object C whose object D was removed, that would normally has the reference info for object D, contains empty square brackets "[]".  

I am using version 1.40.7. The save is done via KCSLinkedAppdataStore and referenceKinveyPropertiesOfObjectsToSave.  Thank you 

Login or Signup to post a comment