CloudKit: Retrieval of CKRecords for conflict resolution on CKErrorCodeServerRecordChanged in CKModifyRecordsOperation does not work.
| Originator: | saschaholesch | ||
| Number: | rdar://21497003 | Date Originated: | 23-Jun-2015 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 8.3 |
| Classification: | Reproducible: | Always |
Summary:
When executing a batch operation using CKModifyRecordsOperation it is not possible to retrieve CKRecords for CKErrorCodeServerRecordChanged. According to the docs and WWDC sessions it should be possible to get 3 records out of the dictionary with the keys:
* CKRecordChangedErrorServerRecordKey
* CKRecordChangedErrorAncestorRecordKey
* CKRecordChangedErrorClientRecordKey
but those keys do not exist in the userInfo dictionary.
Steps to Reproduce:
func pushRecordChangesForZoneID(recordZoneID: CKRecordZoneID) {
// ...
modifyRecordsOperation.modifyRecordsCompletionBlock = { (savedRecords, deletedRecordIDs, error) -> Void in
if (error != nil) {
if error.code == CKErrorCode.PartialFailure.rawValue {
if let errorDict = error.userInfo?[CKPartialErrorsByItemIDKey] as? [CKRecordID : NSError] {
for (recordID, partialError) in errorDict {
if partialError.code == CKErrorCode.ServerRecordChanged.rawValue {
if let userInfo = partialError.userInfo {
if let serverRecord = userInfo[CKRecordChangedErrorServerRecordKey] as? CKRecord
// no Value
}
if let ancestorRecord = userInfo[CKRecordChangedErrorAncestorRecordKey] as? CKRecord
// no Value
}
if let clientRecord = userInfo[CKRecordChangedErrorClientRecordKey] as? CKRecord
// no Value
}
}
}
}
}
}
}
}
Expected Results:
The constants serverRecord, ancestorRecord and clientRecord should hold the respective CKRecords.
Actual Results:
The constants serverRecord, ancestorRecord and clientRecord are not being populated. The userInfo dictionary appears not to carry the CKRecords.
The content of the userInfo dictionaries of partialError:
[NSDebugDescription: CKInternalErrorDomain: 2037, NSLocalizedDescription: Error saving record <CKRecordID: 0x7fb41bf7e640; DA39FE08-AB0B-4F07-A42E-F5732B114706:(userData:__defaultOwner__)> to server: Protection data didn't match, NSUnderlyingError: <CKError 0x7fd89a92d370: "Unknown Error" (2037)>]
The content of the userInfo dictionary of errorDict:
[<CKRecordID: 0x7fb5bb88afa0; C1575083-F992-448A-8D77-D62C4A42D696:(userData:__defaultOwner__)>: <CKError 0x7fb5b961c6a0: "Batch Request Failed" (22/2024); server message = "Atomic failure"; uuid = 1E4C0FD5-EC10-4071-B277-102A9F1B0E5E; container ID = "iCloud.net.neverthesamecolor.atsumeru">, <CKRecordID: 0x7fb5bb848ad0; DA39FE08-AB0B-4F07-A42E-F5732B114706:(userData:__defaultOwner__)>: <CKError 0x7fb5b9653060: "Server Record Changed" (14/2037); "Error saving record <CKRecordID: 0x7fb41bd9ca50; DA39FE08-AB0B-4F07-A42E-F5732B114706:(userData:__defaultOwner__)> to server: Protection data didn't match">]
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
As of 21st Jan 2016 the keys are now filled for me, using the default zone in a public database.
I tried with atomic = NO and same problem, serverRecord is not in the partial error dict.
I tried the same against the iOS 9 SDK (Beta 2+3), with the same result. The result is the same: The constants serverRecord, ancestorRecord and clientRecord are not being populated. The userInfo dictionary appears not to carry the CKRecords.