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.
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.
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)
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.
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…