CloudKit: It's possible to create Users from code and then crash the dashboard

I found a bug in CloudKit today that it is possible to create records in the Users table. This is with the default security settings.


    CKRecord* record = [[CKRecord alloc] initWithRecordType:@"Users" recordID:[[CKRecordID alloc] initWithRecordName:@"test"]];
    CKModifyRecordsOperation* op = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:@[record] recordIDsToDelete:nil];
    op.savePolicy = CKRecordSaveChangedKeys;
    [op setModifyRecordsCompletionBlock:^(NSArray<CKRecord *>* records, NSArray<CKRecordID *> *recordIDs, NSError * _Nullable error) {
        NSLog(@"error %@", error);
    }];
    [[CKContainer defaultContainer].publicCloudDatabase addOperation:op];


Now in CloudKit dashboard go to the public data user records and you'll see the record and when you click it you will crash the dashboard. It's not possible to delete this test 'Users' from the dashboard and attempting it in code doesn't work either:


CKRecord* record = [[CKRecord alloc] initWithRecordType:@"Users" recordID:[[CKRecordID alloc] initWithRecordName:@"test"]];
    CKModifyRecordsOperation* op = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:nil recordIDsToDelete:@[record.recordID]];
    op.savePolicy = CKRecordSaveChangedKeys;
    [op setModifyRecordsCompletionBlock:^(NSArray<CKRecord *>* records, NSArray<CKRecordID *> *recordIDs, NSError * _Nullable error) {
        NSLog(@"error %@", error);
    }];
    [[CKContainer defaultContainer].publicCloudDatabase addOperation:op];


<CKError 0x7f94e9da8590: "Invalid Arguments" (12/2006); server message = "invalid attempt to delete user records directly">


Hopefully this bug can be fixed, and if the 'Users' record type could be renamed to 'User' that would make a lot more sense also, thanks.

Replies

I don't think Apple will respond to bugs posted here. To inform them please see https://developer.apple.com/bug-reporting/.