If a user has duplicate contacts in their Google Contacts, does this
point to:
a) a bug in the API. If so, how to report it?
b) some historical legacy whereby the no-duplicate rule wasn't
always enforced
c) some other reason - eg the no-duplicate rule is enforced for some
clients but not others.
The Google Contacts API serving duplicates to a client seems to violate
the rule of
"be conservative in what you do, be liberal in what you accept
from others"
because the API is serving data to clients that it won't accept in return.
The second part of the question is to invite suggestions on how this
state of affairs should be handled from a client perspective? eg. if
the cause is a) or b) above then perhaps it makes sense to clean up the
duplicates but if it's c) then perhaps it's better to live with them.
Thanks.
Leni.
Sure. Here is an <entry>:
<entry>
<id>http://www.google.com/m8/feeds/contacts/example%40gmail.com/base/1</id>
<updated>2008-07-11T00:00:00.000Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact'/>
<title type='text'>Fred Bloggs</title>
<link rel='self' type='application/atom+xml'
href='http://www.google.com/m8/feeds/contacts/example%40gmail.com/base/1'/>
<link rel='edit' type='application/atom+xml'
href='http://www.google.com/m8/feeds/contacts/example%40gmail.com/base/1/11'/>
<gd:email rel='http://schemas.google.com/g/2005#home'
address='fred....@example.com' primary='true'/>
</entry>
The use-case is the server responding to a GET with a <feed> containing
two <entry>'s identical to the one above except for different <id> and
<updated> elements.
Unless I have misunderstood, it seems reasonable to describe the
<entry>'s as duplicates?
> Basically it is very hard to say if a contact is a duplicate of
> another contact.
It's important to be clear about the rules around conflicts. You have
explained it in the same way as:
http://code.google.com/apis/contacts/developers_guide_protocol.html#Creating
so that's reassuring.
So can I ask again:
- does the <feed> described above represent a server/constraint failure?
If so, that's cool - the intent is not to point the finger, just to be
clear about the rules around conflicts
- any suggestions re: how clients should handle such a <feed>?
Leni.
Hi Wayne,
The criteria for two contacts to be considered identical is that they
have the same email address. This is (or at least should be) enforced
by both GMail and the Contacts API.
In GMail, you'll get the following error:
Error saving data: Cannot have more than one contact with email
address 'te...@example.com'.
In the Contacts API, you'll get an HTTP 409 Conflict status after
submitting the entry.
As for having multiple contacts with the same email address, that's
not currently supported. If that's something you'd like to see added,
please file a feature request here:
http://code.google.com/p/gdata-issues/issues/entry
Regarding creating duplicate contacts on the iPhone, that's
interesting. The OS X sync client uses the exact same Contacts API
everybody else uses. However, I know that there were some earlier bugs
in the API that would permit this under certain circumstances, it's
possible the duplicate was created via one of these bugs before they
were fixed.
--
Trevor Johns
2. what to do when duplicates exist in an account?
My question relates to (2). What should client software do when it is
presented duplicates by the Contacts API?
The trouble is that client software won't be able to edit duplicate
contacts via the API because when it tries to update one of the
duplicates it'll get a 409. So what to do?
And a related question - does Gmail itself use the Contacts API? I am
wondering how a user with duplicate contacts in their account is able to
happily edit their contacts via Gmail?
Regards -
Leni.
Hi Leni,
Sorry for the delay in replying.
To answer your questions:
1. The duplicate contacts are created due to a race condition in our
code. To put it simply, the constraint is enforced at the application
level, not a the storage level. If two of our servers perform an
insert/update at the same time, they may not see the other's changes.
This is how the constraint is being violated.
That being said, this is not a good thing. Even though it's possible
to violate the constraint, there are issues with various services that
can arise because of this. This is a known issue, and we're working on
it.
2. Unfortunately, there's no good solution to this at the moment.
You'll have to manually merge the contacts (I believe that you should
be able to change the email address for one of the contacts to resolve
the conflict -- however, I don't have an account with duplicate
entries to check with, so I could be wrong), or ask the user to do
this themselves via the GMail interface.
GMail does not use the Contacts API. Instead, it ties directly into
the contacts system. As a result, the validation logic can yield
different results on edge cases such as this.
--
Trevor Johns
Though, just to be clear: Please don't write any code that depends on
the existence of the email uniqueness constraint. It's considered to
be a limitation of API and may be removed in a future update to API.
--
Trevor Johns