Rate limited with the response MY_CONTACTS_OVERFLOW_COUNT

931 views Asked by At

I am proto-typing an application using Google new People API. During my testing I have added and deleted contacts in batches, to see how many can be added per minute and per day in total.

I understand the documentation say how many can be added per minute, but from my testing I don't seem to get anywhere close to this. Even when reviewing my metrics, my request is far long than the supposed limits per minute and per day.

My main question I have is after a couple of attempts across a service account on 3 of my gmail account's I am now getting back googleapi: Error 429: MY_CONTACTS_OVERFLOW_COUNT, rateLimitExceeded. I can't find any mention of MY_CONTACTS_OVERFLOW_COUNT online. I assumed from the error it meant I have too many contacts, but when running a delete script it appears I don't have any at all. This response is returned for all 3 accounts on my development machine now for longer than 24 hours, which is making me believe I have possibly been blocked and not rate limited?

Client code for running the test:

package main

import (
    "context"
    "log"
    "google.golang.org/api/people/v1"
    "os"
    "bufio"
    "time"
    //"github.com/davecgh/go-spew/spew"
)


func chunks(xs []string, chunkSize int) [][]string {
    if len(xs) == 0 {
        return nil
    }
    divided := make([][]string, (len(xs)+chunkSize-1)/chunkSize)
    prev := 0
    i := 0
    till := len(xs) - chunkSize
    for prev < till {
        next := prev + chunkSize
        divided[i] = xs[prev:next]
        prev = next
        i++
    }
    divided[i] = xs[prev:]
    return divided
}

func main(){
    
    ctx := context.Background()
    srv, err := people.NewService(ctx)
    if err != nil {
        log.Fatalf("Unable to create people Client %v", err)
    }
    

    file, err := os.Open("test125k.txt")
    if err != nil {
        log.Fatalf("failed opening file: %s", err)
    }

    scanner := bufio.NewScanner(file)
    scanner.Split(bufio.ScanLines)
    var txtlines []string
 
    for scanner.Scan() {
        txtlines = append(txtlines, scanner.Text())
    }

    chunkEmails := chunks(txtlines,200)
    count := 0
    var validPeopleResources []string

    log.Printf("Started")

    for i,chunk := range chunkEmails{ //
        var contacts people.BatchCreateContactsRequest
        contacts.ReadMask = "emailAddresses,photos"
        for _,chunkEmail := range chunk{
            var contact people.ContactToCreate
            var person people.Person
            var personEmails people.EmailAddress
            personEmails.Value = chunkEmail
            var AllEmails  = [](*people.EmailAddress){
                &personEmails,
            }
    
            person.EmailAddresses = AllEmails
            contact.ContactPerson = &person
            contacts.Contacts = append(contacts.Contacts, &contact)
        }

        r,err := srv.People.BatchCreateContacts(&contacts).Do() 
        if err != nil {
            log.Printf("Unable to create contacts")
            log.Printf(err.Error())
            log.Fatalf("")
        }

        var contactEmail string
        
        var resource string
        for _, validPeople := range r.CreatedPeople {
            contactEmail = validPeople.Person.EmailAddresses[0].Value
            resource = validPeople.Person.ResourceName
            validPeopleResources = append(validPeopleResources,resource)
        }
        
        count = count + 1

        if count == 2 {
            var contactToDelete people.BatchDeleteContactsRequest 
            contactToDelete.ResourceNames = validPeopleResources
            _,err = srv.People.BatchDeleteContacts(&contactToDelete).Do()
            if err != nil {
                log.Printf("Unable to delete contacts")
                log.Printf(err.Error())
                log.Fatalf("")
            }
            validPeopleResources = nil
            count = 0
            log.Printf("performed delete")
        }


        log.Printf("%d comlpeted",i)
        time.Sleep(10 * time.Second)
    }
}
1

There are 1 answers

0
Ranjani On

"MY_CONTACTS_OVERFLOW_COUNT" happens when you try to insert new contacts to the Google account, but they already have the maximum number of contacts.

The max limit is 25,000, since 2011: https://workspaceupdates.googleblog.com/2011/05/need-more-contacts-in-gmail-contacts.html

It should be noted here that Google also takes the deleted contacts into account for calculating the count. You can find the deleted contacts in the Contacts Trash. These contacts will be cleared after 30 days.