zilzar / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

User Defined Fields on Contacts are fail validation on save if key or value are empty #518

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download a contact with a udf that has either key or value empty
<gContact:userDefinedField key='' value='value1'/>
2. Try to upload it back - you get a validation failure

What is the expected output? What do you see instead?
Expected: Output - save operation succeeds. 
Actual: Validation fails because the empty attribute is not saved in the xml:
<gContact:userDefinedField value="value1" />

What version of the product are you using? On what operating system?
1.8.0?

I managed to do a fix with the following changes. Please review and maybe 
commit.

ExtensionBase class:340 changed from:
if (Utilities.IsPersistable(name) && Utilities.IsPersistable(value)) 
to 
if (IsPersistable(name, value))

Added in the ExtensionBase class a method:
protected virtual bool IsPersistable(string name, string value)
{
    return Utilities.IsPersistable(name) && Utilities.IsPersistable(value);
}
This maintains compatibility with the existing test.
Then override the method in the UserDefinedField class in the 
Google.GData.Contacts namespace with:
protected override bool IsPersistable(string name, string value)
{   // validation on Google side requires that we always pass in name and value
    return true;
}
This will force that an empty key or empty value will always be saved in the 
outgoing XML.

Original issue reported on code.google.com by corneliu...@gtempaccount.com on 21 Jun 2011 at 11:40

GoogleCodeExporter commented 9 years ago
Corneliu,

Thanks for your bug report and for the patch, however, before committing your 
code I wanted to double check with the Contacts API engineers in order to 
understand whether we were doing the right thing.

What I found out is that the API requires both the key and the value to be 
present and non-empty when adding an user-defined field, so the validation in 
place is correct.
Thanks

Claudio

Original comment by ccherub...@google.com on 22 Jun 2011 at 1:42

GoogleCodeExporter commented 9 years ago
OK, so in the Gmail Contact Manager UI I created a new contact "John Doe" and 
added a new custom field with "MyCustomFieldName" and "MyCustomFieldValue" as 
the key value pair and this is the entry that comes back in the XML response:

<entry>
    <id>http://www.google.com/m8/feeds/contacts/username%40gmail.com/base/[removed]</id>
    <updated>2011-11-09T01:23:28.925Z</updated>
    <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
    <title type="text">John Doe</title>
    <link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/username%40gmail.com/[removed]"/>
    <link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/username%40gmail.com/full/[removed]"/>
    <link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/username%40gmail.com/full/[removed]"/>
</entry>

Original comment by dave.r...@gmail.com on 9 Nov 2011 at 1:31

GoogleCodeExporter commented 9 years ago
If the XML doesn't contain the custom fields, then this is not a bug in the 
.NET client library, but instead it seems like there's something wrong with the 
Contacts API.
Please ask for support in the Contacts API forum:

http://code.google.com/apis/contacts/community/

Thanks
Claudio

Original comment by ccherub...@google.com on 9 Nov 2011 at 1:38