A partial archive of meta.discourse.org as of Tuesday July 18, 2017.

Badge Error 500

romainreuillon

Hello,

do you have any idea why this would append ?


It append for only 1 user. The discourse version is 1.8.3. May I provide more detailed info?

Cheers,
Romain

joffreyjaffeux

Hi Romain, did you try to look at your logs ?

romainreuillon

Here is what I get in production.log:

Started GET "/user-badges/jopasserat.json?grouped=true&_=1499926780204" for xx.xx.xx.xx at 2017-07-13 06:36:22 +0000
Started GET "/draft.json?draft_key=new_private_message&_=1499926780205" for xx.xx.xx.xx at 2017-07-13 06:36:22 +0000
Processing by DraftController#show as JSON
  Parameters: {"draft_key"=>"new_private_message", "_"=>"1499926780205"}
Processing by UserBadgesController#username as JSON
  Parameters: {"grouped"=>"true", "_"=>"1499926780204", "username"=>"jopasserat"}
Completed 200 OK in 15ms (Views: 0.4ms | ActiveRecord: 5.6ms)
Completed 500 Internal Server Error in 59ms (ActiveRecord: 25.8ms)
NoMethodError (undefined method `position' for nil:NilClass)
/usr/src/app/app/serializers/basic_user_badge_serializer.rb:11:in `grouping_position'
romainreuillon

In non grouped mode I get the same kind of error:

Started GET "/u/jopasserat.json?stats=false&_=1499926914209" for xx.xx.xx.xx at 2017-07-13 06:43:52 +0000
Processing by UsersController#show as JSON
  Parameters: {"stats"=>"false", "_"=>"1499926914209", "username"=>"jopasserat"}
Completed 200 OK in 284ms (Views: 0.2ms | ActiveRecord: 69.3ms)
Started GET "/admin/dashboard/problems.json?_=1499926914211" for xx.xx.xx.xx at 2017-07-13 06:44:02 +0000
Started GET "/admin/dashboard.json?_=1499926914210" for xx.xx.xx.xx at 2017-07-13 06:44:02 +0000
Processing by Admin::DashboardController#problems as JSON
  Parameters: {"_"=>"1499926914211"}
Processing by Admin::DashboardController#index as JSON
  Parameters: {"_"=>"1499926914210"}
Completed 200 OK in 299ms (Views: 0.3ms | ActiveRecord: 0.0ms)
Completed 200 OK in 616ms (Views: 14.9ms | ActiveRecord: 0.0ms)
Started GET "/admin/badges.json?_=1499926914212" for xx.xx.xx.xx at 2017-07-13 06:44:05 +0000
Processing by Admin::BadgesController#index as JSON
  Parameters: {"_"=>"1499926914212"}
Completed 200 OK in 69ms (Views: 0.2ms | ActiveRecord: 6.5ms)
Started GET "/admin/users/list/active.json?_=1499926914213" for xx.xx.xx.xx at 2017-07-13 06:44:09 +0000
Processing by Admin::UsersController#index as JSON
  Parameters: {"_"=>"1499926914213", "query"=>"active"}
Completed 200 OK in 59ms (Views: 0.4ms | ActiveRecord: 5.8ms)
Started GET "/admin/users/3.json?_=1499926914214" for xx.xx.xx.xx at 2017-07-13 06:44:13 +0000
Processing by Admin::UsersController#show as JSON
  Parameters: {"_"=>"1499926914214", "id"=>"3"}
Completed 200 OK in 136ms (Views: 0.4ms | ActiveRecord: 71.9ms)
Started GET "/admin/groups.json?_=1499926914215" for xx.xx.xx.xx at 2017-07-13 06:44:14 +0000
Processing by Admin::GroupsController#index as JSON
  Parameters: {"_"=>"1499926914215"}
Completed 200 OK in 11ms (Views: 0.2ms | ActiveRecord: 2.5ms)
Started GET "/user-badges/jopasserat.json?_=1499926914216" for xx.xx.xx.xx at 2017-07-13 06:44:17 +0000
Processing by UserBadgesController#username as JSON
  Parameters: {"_"=>"1499926914216", "username"=>"jopasserat"}
Completed 500 Internal Server Error in 195ms (ActiveRecord: 98.1ms)
NoMethodError (undefined method `position' for nil:NilClass)
mpalmer

You have a badge without a badge grouping. Based on a look at the database schema, that isn’t supposed to be possible. What badges does this user have? Do you have any custom badges defined? Are you comfortable rummaging around in the database using the command line?

romainreuillon

I was creating and assigning many badges when it happened. I reassigned the group for each of these badges and it fixed the pb. All of them apparently had a group, but reassign the group anyway did the trick.