Reset the user-selectable avatar Ops-error 500

AI-generated summary

A bug was reported in Discourse v2.9.3 beta where resetting the user-selectable avatar setting causes an Ops-error 500, rendering the site inaccessible. daming first noticed the issue, which persisted after a brief recovery. JammyDodger replicated the error and identified a NoMethodError in the logs related to to_i being called on an empty array, indicating a problem when the avatar list is empty while selectable avatars are enabled. pfaffman suggested checking logs and disabling the setting via Rails console, which JammyDodger confirmed resolved the issue by running SiteSetting.selectable_avatars_mode="disabled". daming confirmed the fix. sam acknowledged the bug and confirmed it was fixed in a subsequent PR 16302.

When I add a user-selectable avatar, and then reset the user-selectable avatar, it suddenly shows an Ops-error 500, and then I can’t do anything.

Add:This happened once before, but it disappeared after ten minutes. v2.9.3 beta

After half an hour it was working fine

But magically after half an hour I didn’t do anything and it didn’t work again,Show the same error page.

3 Likes

I can replicate this (136f7dbf78)

  • Added a couple of selectable avatars
  • Enabled selectable avatars mode for everyone

  • Reset selectable avatars, though the green tick was unpressable
  • Reset selectable avatars mode
  • Got ‘Ooops. The software powering this discussion…’

I can’t get rid of the Ooops screen. :thinking: My test site is now down and out, across both test user and admin, on Chrome and Firefox.

5 Likes

Check the logs in /var/discourse/shared/standalone/logs/rails/production.log and see what the error is and report that.

And then you can go into rails and un-do the changes you made. I think with something like

    Sitesettings.selectable_avatar_whatever=false

You can use tab completion after you type selectable or maybe start with avatar? I don’t know how that stuff works off the top of my head.

4 Likes

I have jumped on my laptop to have a look at the logs. I’m still fairly new at this, so correct me if I’ve pulled out the wrong thing. :slight_smile:

Started PUT "/admin/site_settings/selectable_avatars" for 176.25.113.180 at 2022-03-26 10:09:12 +0000
Processing by Admin::SiteSettingsController#update as */*
  Parameters: {"selectable_avatars"=>"", "id"=>"selectable_avatars"}
Completed 500 Internal Server Error in 62ms (ActiveRecord: 0.0ms | Allocations: 3529)
NoMethodError (undefined method `to_i' for []:Array
Did you mean?  to_s
               to_a
               to_h)

I think that is the original error, though there are more from my attempts to access different pages after. Is that the right thing?

Taking a closer look, it appears the errors are the same, just triggered by different pages:

Started GET "/login" for 176.25.113.180 at 2022-03-26 10:21:13 +0000
Processing by StaticController#show as HTML
  Parameters: {"id"=>"login"}
Completed 500 Internal Server Error in 9ms (ActiveRecord: 0.0ms | Allocations: 1824)
NoMethodError (undefined method `to_i' for []:Array
Did you mean?  to_s
               to_a
               to_h)
3 Likes

I think it’s that the selectable avatar setting it on but the avatar list is empty (that’s the empty array that is causing the error, I think) . So you need to either disable selectable avatars or add some avatars. I don’t know how to add them offhand, so disabling the setting I think might work.

4 Likes

Sorry for the delay, that took me longer than expected to land on the right words. :slightly_smiling_face:

SiteSetting.selectable_avatars_mode="disabled"

Running that has now returned my test site to me. :+1:

4 Likes

Thanks guys, I got it !

4 Likes

Nice work, @JammyDodger! You can take out some of the guesswork by looking in conf/site_settings.yml in the source. They way you can more easily search for what you’re looking for. You can also attach /search in the ux, but here the ux was broken…

Glad you’re back in business @daming!

This does still seem like a bug. I’m sure it’ll get attention after the weekend.

3 Likes

We will have a look over the next 7 days or so. Happy we have a workaround.

3 Likes

We have this fixed per:

https://github.com/discourse/discourse/pull/16302

:confetti_ball:

5 Likes