Validation error: unique_post_validator() doesn't know who the acting user is

I’m seeing similar errors on at least 2 different discourse installations. Does anyone have any idea what the following is about?

The most serious manifestation is when trying to post from the web interface, which fails with a 500 error. the rails/production.log has the following:

Started POST "/posts" for 212.139.89.48 at 2016-09-15 10:56:19 +0000
Processing by PostsController#create as JSON
  Parameters: {"raw"=>"If you are applying for a person over 18 and they need someone to accompany them on the bus you will need to get a letter from their Doctor stating that they cannot travel without support.  That way they will be able to get a +1.  If under 18 thats not a problem", "unlist_topic"=>"false", "category"=>"6", "topic_id"=>"1029", "is_warning"=>"false", "whisper"=>"false", "archetype"=>"regular", "typing_duration_msecs"=>"29600", "composer_open_duration_msecs"=>"123882", "reply_to_post_number"=>"1", "nested_post"=>"true"}
Completed 500 Internal Server Error in 191ms (ActiveRecord: 2.5ms)
NoMethodError (undefined method `staff?' for nil:NilClass)
/var/www/discourse/lib/validators/post_validator.rb:94:in `unique_post_validator'

I also see another variant, which turns up in an email which is copied in the production.log file. The email contains a similar error, but this time with a backtrace:

Unrecognized error type (NoMethodError: undefined method `staff?’ for nil:NilClass) when processing incoming email

Backtrace:
/var/www/discourse/lib/validators/post_validator.rb:94:in unique_post_validator' /var/www/discourse/lib/validators/post_validator.rb:20:in validate’
/var/www/discourse/lib/new_post_manager.rb:85:in default_handler' /var/www/discourse/lib/new_post_manager.rb:133:in call’
/var/www/discourse/lib/new_post_manager.rb:133:in block in perform' /var/www/discourse/lib/new_post_manager.rb:132:in any?’
/var/www/discourse/lib/new_post_manager.rb:132:in perform' /var/www/discourse/lib/email/receiver.rb:501:in create_post’
/var/www/discourse/lib/email/receiver.rb:470:in create_post_with_attachments' /var/www/discourse/lib/email/receiver.rb:427:in create_reply’
/var/www/discourse/lib/email/receiver.rb:348:in process_destination' /var/www/discourse/lib/email/receiver.rb:101:in block in process_internal’
/var/www/discourse/lib/email/receiver.rb:99:in yield' /var/www/discourse/lib/email/receiver.rb:99:in yield’
/var/www/discourse/lib/email/receiver.rb:99:in each' /var/www/discourse/lib/email/receiver.rb:99:in each’
/var/www/discourse/lib/email/receiver.rb:99:in each' /var/www/discourse/lib/email/receiver.rb:99:in each’
/var/www/discourse/lib/email/receiver.rb:99:in each' /var/www/discourse/lib/email/receiver.rb:99:in each’
/var/www/discourse/lib/email/receiver.rb:99:in process_internal' /var/www/discourse/lib/email/receiver.rb:43:in process!’
/var/www/discourse/lib/email/processor.rb:17:in process!' /var/www/discourse/lib/email/processor.rb:11:in process!’
/var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:25:in process_popmail' /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:36:in block (2 levels) in poll_pop3’
/usr/local/lib/ruby/2.3.0/net/pop.rb:689:in block in delete_all' /usr/local/lib/ruby/2.3.0/net/pop.rb:688:in each’
/usr/local/lib/ruby/2.3.0/net/pop.rb:688:in delete_all' /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:35:in block in poll_pop3’
/usr/local/lib/ruby/2.3.0/net/pop.rb:532:in start' /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:34:in poll_pop3’
/var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:16:in execute' /var/www/discourse/app/jobs/base.rb:154:in block (2 levels) in perform’

Some more info.

  • The problem started when the last discourse update was put through from within the discourse web interface
  • launcher rebuild doesn’t fix it.
  • It seems it matters who the posting user is. Provisionally, it might be that higher trust level users are affected and low trust level not so. An admin user with low trust level is not affected.

getting the same error on posting replies…not all users or all replies :

Completed 500 Internal Server Error in 134ms (ActiveRecord: 4.3ms)
NoMethodError (undefined method staff?' for nil:NilClass) /var/www/discourse/lib/validators/post_validator.rb:94:inunique_post_validator’

I believe this bug was already fixed today, so pull latest and rebuild?

1 Like