sunlightlabs / opencongress

An open website for opening Congress.
http://www.opencongress.org
GNU General Public License v3.0
48 stars 16 forks source link

Seeds without bodies cause errors on confirmation #415

Open jcarbaugh opened 10 years ago

jcarbaugh commented 10 years ago

It's possible for an incoming email to create a seed even when it does not have a body. When the confirmation link is clicked, ActiveRecord validation fails because body is a required field on a FormageddonLetter.

See https://app.getsentry.com/opencongress/oc-production/group/22165844/

crdunwel commented 10 years ago

FormageddonLetter is a strange beast. For instance, part of its class definition comes in a gem from https://github.com/sunlightlabs/formageddon using a funky dependency import at the top of formageddon_letter.rb. Presently we seem to be depending on a try/catch in email_congress_controller.rb to rescue the problem in the confirm method. Raven captures the exception and the user is redirected to complete_profile.

crdunwel commented 10 years ago

On closer examination, this may be intended behavior as the error hits in a " ActiveRecord::Base.transaction ... end" block so any database changes should be undone if a validation error strikes at any point in that code. Perhaps a more specific rescue case to handle this specific problem and be more friendly to the user would be helpful?