cozy / cozy-contacts-v2

Contact books manager for Cozy
http://cozy.io
GNU Affero General Public License v3.0
20 stars 20 forks source link

Uncaught TypeError: e.toLowerCase is not a function #259

Open clochix opened 8 years ago

clochix commented 8 years ago

See rems errors in this feed:

Seen in a user's logs:

error - contact:application | {"type":"error","href":"https://xxxx.cozycloud.cc/apps/contacts/#contacts","url":"https://xxxx.cozycloud.cc/apps/contacts/scripts/vendor.js","line":"7","col":"4299"}
error - contact:application | Uncaught TypeError: e.toLowerCase is not a function
error - contact:application | TypeError: e.toLowerCase is not a function
    at Object.e.match (https://xxxx.cozycloud.cc/apps/contacts/scripts/vendor.js:7:4299)
    at https://xxxx.cozycloud.cc/apps/contacts/scripts/app.js:3:30935
    at Array.reduce (native)
    at o.exports.o.match (https://xxxx.cozycloud.cc/apps/contacts/scripts/app.js:3:30891)
    at https://xxxx.cozycloud.cc/apps/contacts/scripts/app.js:1:5774
    at l (https://xxxx.cozycloud.cc/apps/contacts/scripts/vendor.js:1:17069)
    at ae (https://xxxx.cozycloud.cc/apps/contacts/scripts/vendor.js:1:5383)
    at Function.Kr (https://xxxx.cozycloud.cc/apps/contacts/scripts/vendor.js:1:26032)
    at o.filter (https://xxxx.cozycloud.cc/apps/contacts/scripts/vendor.js:4:21442)
    at t.o.exports.t.setQuery (https://xxxx.cozycloud.cc/apps/contacts/scripts/app.js:1:6919)
gregorylegarec commented 8 years ago

This issue seems to be caused by calling Fuzzy.match with a non-string target object, at this line https://github.com/cozy/cozy-contacts/blob/master/client/app/models/contact.coffee#L185

As I am not able to reproduce it manually, I forced the issue by passing non-string object to Fuzzy.match and reproduced the exact same error.

https://github.com/cozy/cozy-contacts/pull/294 is an attempt to fix this issue.