mysociety / popit

DEPRECATED - Development on PopIt has stopped and it is no longer being maintained
https://goo.gl/Vvej4Q
Other
76 stars 33 forks source link

Internal Server Error 500 without traceback for sinar-malaysia organizations #844

Closed kaerumy closed 9 years ago

kaerumy commented 9 years ago

https://sinar-malaysia.popit.mysociety.org/organizations

Possibly due to a null field in organization or bad data entered via API, but we cannot debug without traceback.

chrismytton commented 9 years ago

@kaerumy Thanks for reporting this, I'm looking into it now.

chrismytton commented 9 years ago

The error I'm seeing in the logs is as follows:

App 22034 stderr: 
App 22034 stderr: /data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/lib/apps/generic_document.js:254
App 22034 stderr:           name1 = name1.toLowerCase();
App 22034 stderr:                 
App 22034 stderr:         ^
App 22034 stderr: TypeError: Object Parti Islam Semalaysia,Parti Islam Semalaysia has no method 'toLowerCase'
App 22034 stderr:     at sortNames (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/lib/apps/generic_document.js:254:25)
App 22034 stderr:     at Array.sort (native)
App 22034 stderr:     at Promise.<anonymous> (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/lib/apps/generic_document.js:251:21)
App 22034 stderr:     at Promise.<anonymous> (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
App 22034 stderr:     at Promise.emit (events.js:95:17)
App 22034 stderr:     at Promise.emit (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
App 22034 stderr:     at Promise.fulfill (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
App 22034 stderr:     at Promise.resolve (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/node_modules/mongoose/lib/promise.js:108:15)
App 22034 stderr:     at Promise.<anonymous> (/data/vhost/popit.mysociety.org/popit-2015-04-29T15-47-08/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
App 22034 stderr:     at Promise.emit (events.js:95:17)

It's caused by this organization - https://sinar-malaysia.popit.mysociety.org/api/v0.1/organizations/556c76528aaf69205fde4d83 - whose name property is an array of strings, rather than just a plain string. If you update this record so the name is just a string then that should fix the error.

Hope that helps!

sweemeng commented 9 years ago

Solved thanks a lot.

chrismytton commented 9 years ago

Great, glad you managed to fix it :smiley:

tmtmtmtm commented 9 years ago

PopIt should really handle problems like this more gracefully, though — so perhaps this should be left open? Or is it already covered by another ticket?

chrismytton commented 9 years ago

@tmtmtmtm Yep fair point, I've opened https://github.com/mysociety/popit/issues/845 for handling errors like these better.