Malformed poll causing server error


I made a mistake making a quick manual adjustment to a poll. The draft saved fine, but when I tried to post it, I got an “Internal Server Error.” I wasted quite a bit of time trying to figure out what was wrong. Some better feedback would have helped. I had no suspicion concerning my poll.

(David Taylor) #2

A server error definitely shouldn’t happen for a malformed poll! Can you post the markup you used here? (Enclose it in [code][/code] if it decides to cause an issue here :wink: )


The reason I didn’t suspect the poll is because it renders fine in the preview area. Here’s the code (and yes, I tried to post the actual poll, but it did the same thing here):

[poll type=single results= on_vote min=1 max=4]

* Regularly
* Sometimes
* Rarely
* Never


(Sam Saffron) #4
ArgumentError ('single' is not a valid type)
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/enum.rb:140:in `assert_valid_value'

/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/enum.rb:140:in `assert_valid_value'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activemodel-5.2.0/lib/active_model/attribute.rb:71:in `with_value_from_user'


/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/persistence.rb:52:in `create!'
/var/www/discourse/plugins/poll/plugin.rb:238:in `create!'

We are trying to set a value on an enum that is not allowed and not handling the exception.

(Jeff Atwood) #6

That’s a good repro, thanks!

(Régis Hanol) #8

@nbianca can you make sure we’re properly handling this exception and showing the proper error message to the user?

(Bianca) #9

Added argument validation in

(Jeff Atwood) #10