2
votes

I am attempting to save a CKRecord using a CKModifyRecordsOperation and every time I try it, I get this initial error:

["CKErrorDescription": Failed to modify some records,

"CKPartialErrors": { "CKRecordID: 0x60c000034000; recordName=ABC, zoneID=workspaceZone:DEF" = "CKError 0x60c000257340: \"Batch Request Failed\" (22/2024); \"Record CKRecordID: 0x7fb2f6998a60; recordName=ABC, zoneID=workspaceZone:DEF will not be saved because of previous error in atomic zone\""; },

"NSDebugDescription": CKInternalErrorDomain: 1011, "NSUnderlyingError": CKError 0x60c000248af0: "Partial Failure" (1011); "Failed to modify some records"; partial errors: { ... 1 "Batch Request Failed" CKError's omited ... },

"NSLocalizedDescription": Failed to modify some records]

I then parse the individual errors of the batch like this:

if let errorItems = error.partialErrorsByItemID {
  for item in errorItems{
    if let itemError = item.value as? CKError{
      print("::: Individual Error in Batch :::")
      print(itemError)
      print(":::::")
    }
  }
}

But all the individual error says is:

CKError(_nsError: CKError 0x60c000257340: "Batch Request Failed" (22/2024); "Record CKRecordID: 0x7fb2f6998a60; recordName=GHI, zoneID=workspaceZone:JKL will not be saved because of previous error in atomic zone")

The CloudKit server log just says it's a BAD_REQUEST which isn't very helpful either.

Is there a way to get more details as to what's wrong with my record?

1
Clifton, can you try and work out which record is causing this error, and maybe work out what is going wrong from there? What is the significance of 22/2024? are you modifying 2024 records by any chance? could it be record 22 is the problem? A wild guess? Let me know? What are the other details given here? GHI? JKL? referring too? Does that help you get any closer to the problem?user3069232
I was finally able to get this working by deleting my zone and re-creating it. I think it got corrupted somehow because one of my Record Types wasn't accepting new record creations. After deleting the record type, creating it, deleting the zone, and then creating it again, it is working again. Weird (and scary) that this could happen!Clifton Labrum
Great, but out of interest... was there 2024 records?user3069232
No, I only had about 15 records total across all record types.Clifton Labrum

1 Answers

1
votes

This just means one of your requests failed. You're doing a batch request with one or more requests. If one fails, CloudKit fails all of the requests to keep things atomic.

So, you should subscribe to errors on each record with perRecordCompletionBlock. Then, you can see which record is failing and why. You should print out the userInfo dictionary of the error for more detailed information.