michael-adler / sync-google-contacts

Automatically exported from code.google.com/p/sync-google-contacts
18 stars 12 forks source link

Server 400 error adding UID field to Contact record #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Checkout source && edit ~/.google/config with valid values
2. Run `contact-sync --user=firstuser --user=seconduser --debug`

This results in the following error:

user@host:~❯ ./bin/contacts-sync --user=firstuser --user=seconduser --debug
./bin/contacts-sync:39: DeprecationWarning: the sets module is deprecated
  import sets
Add UID 54ad61c6-1493-11e1-b6fc-003048d320ee to "Some Contact" 
(firstuser@appsdomain.com)
Traceback (most recent call last):
  File "./bin/contacts-sync", line 757, in <module>
    main()
  File "./bin/contacts-sync", line 737, in main
    contacts.append(UserContacts(users[i]))
  File "./bin/contacts-sync", line 128, in __init__
    entry = self.gd_client.Update(entry)
  File "/home/user/lib/python/gdata/client.py", line 730, in update
    desired_class=entry.__class__, **kwargs)
  File "/home/user/lib/python/gdata/client.py", line 319, in request
    RequestError)
gdata.client.RequestError: Server responded with: 400, [Line 1, Column 237, 
element ns2:userDefinedField] Missing attribute: &#39;key&#39;

I am running revision 6 on trunk with gdata 2.0.15

Original issue reported on code.google.com by meanderi...@silverleafstudios.net on 21 Nov 2011 at 11:00

GoogleCodeExporter commented 9 years ago
The erroneous line seems to be the first nested tag:

<ns2:userDefinedField value="null" 
xmlns:ns2="http://schemas.google.com/contact/2008" />

Which is line 2 of the attached text parsed from printing the "entry" variable 
before the call to `self.gd_client.Update(entry)` on line 127 of contact-sync 
[note: it is line 128 in my original report because I added a line to append to 
the python path near the beginning of the file)

Original comment by meanderi...@silverleafstudios.net on 22 Nov 2011 at 8:54

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Somehow that contact is malformed.  userDefinedField is supposed to have both a 
key and a value.  At the point of the failure the script has added a field to 
an existing contact read from the server and is just trying to write back the 
updated contact.  It appears the failure is outside the script, either in the 
gdata library or in a broken contact on the server.

I tried creating a contact with a user-defined field.  With the GUI it is not 
possible to create one with just a key and no value.  It is, however, possible 
to create a contact with an empty key and a non-empty value.  The gdata API 
fails on update with such a field.

I'm not inclined to fix this with a hack in the script.  Others have noted the 
same problem, e.g. https://code.google.com/p/google-gdata/issues/detail?id=518

Original comment by mad...@tapil.com on 23 Nov 2011 at 2:34