CKQueryOperation got error "No operations present in request" randomly

172 views Asked by At

I'm trying to fetch some records from Cloud Server w/ the code snippet below. It returns records w/o any error in most times:

CKQuery * query = [[CKQuery alloc] initWithRecordType:@"MyTable"
                                            predicate:[NSPredicate predicateWithFormat:@"accountID = 1"]];
CKQueryOperation * recordFetchOperation = [[CKQueryOperation alloc] initWithQuery:query];
recordFetchOperation.database = [[CKContainer defaultContainer] privateCloudDatabase];
recordFetchOperation.recordFetchedBlock = ^(CKRecord *record) {
  // get records succeed some times
};
recordFetchOperation.queryCompletionBlock = ^(CKQueryCursor *cursor, NSError *operationError) {
  if (operationError) [self _handleError:operationError];
};

... // some other operations

NSOperationQueue * queue = [[NSOperationQueue alloc] init];
[queue addOperations:@[recordFetchOperation, ...]
   waitUntilFinished:NO];

But sometimes, it returns error:

{
NSDebugDescription = "CKInternalErrorDomain: 1009";
NSLocalizedDescription = "No operations present in request";
NSUnderlyingError = "Error Domain=CKInternalErrorDomain Code=1009 \"No operations present in request\" UserInfo={NSLocalizedDescription=No operations present in request}";
}

I've checked the error code, it's CKErrorInvalidArguments, which as doc said

Bad client request (bad record graph, malformed predicate)

I've no idea how this error comes and how to handle this error, unlike CKErrorNetworkUnavailable error, it does not have CKErrorRetryAfterKey value in error.userInfo for me to send the request after a time interval.


Btw, when I got this error, all my operations will have this error w/o any record returned.

0

There are 0 answers