CloudKit Batch Error: Previous Error in Atomic Zone

588 views Asked by At

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

There are 1 answers

0
plivesey On

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.