Diego81 / omnicontacts

A generalized Rack middleware for importing contacts from major email providers.
477 stars 231 forks source link

gmail contacts import breaks if contact has no name or email #121

Closed koryteg closed 9 years ago

koryteg commented 9 years ago

I had a contact in gmail that was just a phone number(don't ask me how). but I get this error: undefined method `[]' for nil:NilClass

block in OmniContacts::Importer::Gmail#contacts_from_response on line 91: contact[:first_name], contact[:last_name], contact[:name] = email_to_name(contact[:emails][0][:email]) if contact[:name].nil? && contact[:emails][0][:email]

the error comes from contact[:emails][0][:email] because you cant call [:email] on nil ( because contact[:emails][0] is nil).

rubytastic commented 9 years ago

Could you please use the source of this repo and not the gem version if not done already? The gem has to be build newly but I cannot do this without Diego giving me more rights.

Perhaps if problem persist you can make pull request, happily to merge in

rubytastic commented 9 years ago

@koryteg Some basic validation should fix this but I don't have time. Can you make a pull request checking if any values are nil?

rubiety commented 9 years ago

I was running into the same issue and made pull request #122. I think the existing nil check there was just slightly off.