anchor.diff:          remainingEntities = limit - returnedEntities.length;
         }
   
  -      bool isLast = ((limit != null && remainingEntities == 0) ||
  -                     response.batch.moreResults == 'NO_MORE_RESULTS');
  +      // If the server signals there are more entities and we either have no
  +      // limit or our limit has not been reached, we set `moreBatches` to
  +      // `true`.
  +      bool moreBatches =
  +          (remainingEntities == null || remainingEntities > 0) &&
  +          response.batch.moreResults == 'MORE_RESULTS_AFTER_LIMIT';
  +
  +      bool gotAll = limit != null && remainingEntities == 0;
  +      bool noMore = response.batch.moreResults == 'NO_MORE_RESULTS';
  +      bool isLast = gotAll || noMore;
  +
  +      // As a sanity check, we assert that `moreBatches XOR isLast`.
  +      assert (isLast != moreBatches);
  +
  +      // FIXME: TODO: Big hack!
  +      // It looks like Apiary/Atlas is currently broken.
  +      if (moreBatches && returnedEntities.length == 0) {
  +        print('Warning: Api to Google Cloud Datastore returned bogus response. '
  +              'Trying a workaround.');
  +        isLast = true;
  +        moreBatches = false;
  +      }
   
         if (!isLast && response.batch.endCursor == null) {
           throw new datastore.DatastoreError(
  
positive.code:             '(${request.query.limit}) was.');
        }
  
        if (limit != null &&
            returnedEntities.length < batchLimit &&
            response.batch.moreResults == 'MORE_RESULTS_AFTER_LIMIT') {
  
negative.code: }
  
  class DatastoreImpl implements datastore.Datastore {
    static const List<String> Scopes = const [
        api.DatastoreApi.DatastoreScope
    ];
  
    final api.DatastoreApi _api;
    final String _project;
  
  