Badge creation fails with "ActiveRecord::RecordInvalid" error in log


(Lee_Ars) #1

Repro: I attempt to create a badge, supplying name, type, and description. I do not click the “Allow badge to be used as a title” checkbox.

Clicking “Save” results in the save button going disabled and Discourse display “Saving…”, and it hangs there.

Checking /logs shows this error:

ActiveRecord::RecordInvalid (Validation failed: Allow title is not included in the list):
  app/controllers/admin/badges_controller.rb:10:in `create'
  lib/middleware/anonymous_cache.rb:119:in `call'

Info:

ActiveRecord::RecordInvalid (Validation failed: Allow title is not included in the list):
  app/controllers/admin/badges_controller.rb:10:in `create'
  lib/middleware/anonymous_cache.rb:119:in `call'
  config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
  config/initializers/silence_logger.rb:24:in `call'
  lib/middleware/unicorn_oobgc.rb:95:in `process_client'

Backtrace:

/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/logster-0.0.9/lib/logster/logger.rb:44:in `add'
/usr/local/lib/ruby/2.0.0/logger.rb:463:in `fatal'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:81:in `block in log_error'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/deprecation/reporting.rb:34:in `silence'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/deprecation/instance_delegator.rb:19:in `silence'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:77:in `log_error'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:34:in `render_exception'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:27:in `rescue in call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/logster-0.0.9/lib/logster/middleware/reporter.rb:20:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in `call_app'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:22:in `call'
/var/www/discourse/config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
/var/www/discourse/config/initializers/silence_logger.rb:24:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiler.rb:300:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/engine.rb:514:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/application.rb:144:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in `method_missing'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:572:in `process_client'
/var/www/discourse/lib/middleware/unicorn_oobgc.rb:95:in `process_client'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:666:in `worker_loop'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:521:in `spawn_missing_workers'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:140:in `start'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/bin/unicorn:126:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
/var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'

Env:

HTTP_HOST: discourse.bigdinosaur.org
REQUEST_URI: /admin/badges
REQUEST_METHOD: POST
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0
HTTP_ACCEPT: */*
HTTP_REFERER: http://discourse.bigdinosaur.org/admin/badges
HTTP_X_FORWARDED_FOR: 10.10.10.110, 10.10.10.110, 10.10.10.4
HTTP_X_REAL_IP: 10.10.10.4
username: Lee_Ars

Creating the badge with the “Allow badge to be used as title” box checked allows creation to proceed normally and without issue.

Discourse is current at b4c4cc2.


(Vikhyat Korrapati) #2

Fixed in this commit which I added to the latest badge system PR:

https://github.com/vikhyat/discourse/commit/0af28c7a9383af55e3c19de3096ec6c8ce0d3249


(Sam Saffron) #3