שגיאה 500 בעמוד קטגוריה ובעמוד הבית לאחר שדרוג ל-2.6

סיכום מבוסס בינה מלאכותית

After upgrading Discourse from 2.4 to 2.6, Olivier_Baillon encountered a persistent Error 500 on the homepage and category pages, despite successful rebuilds and working admin/user interfaces. Logs repeatedly showed a NoMethodError (undefined method 'hex' for nil:NilClass) originating from app/models/upload.rb and traced to group.rb:767 in flair_url 4. Safe mode and plugin deactivation didn’t help 5. Initially suspected category images 8, but none were present 10. michaeld correctly identified corrupted or missing group flair uploads as the culprit and advised removing or reuploading group flair avatars 13. pfaffman confirmed the fix and provided a Rails console snippet to identify and repair affected groups, which resolved the issue. Olivier_Baillon thanked both for their help, acknowledging he wouldn’t have found the solution alone.

Hi,

I just have upgraded my forum ( working since 2017 ) to 2.6 ( from 2.4)
During the upgrade i notice that Postgresql 9.5 has been replaced by postgres 12.

the rebuild operation has ended without errors but i have an error 500 on homepage ( or a oops message )
Same error on category page.
The admin is working, the user profil is working , the user list is working, a single post is working.
The top refered in admin is not working.

I have no ideas to solve that.
Thanks you very much

Any plugin installed?

Anything in /logs?

You are right, i have many many times the same error in /logs

NoMethodError (undefined method hex' for nil:NilClass) app/models/upload.rb:180:in base62_sha1’
app/models/upload.rb:174:in short_path' app/models/upload.rb:146:in short_path’
app/models/group.rb:767:in flair_url' (eval):5:in _fast_attributes’
lib/freedom_patches/ams_include_without_root.rb:54:in include!' lib/freedom_patches/ams_include_without_root.rb:57:in include!’
lib/freedom_patches/ams_include_without_root.rb:57:in include!' app/controllers/application_controller.rb:440:in serialize_data’
app/controllers/application_controller.rb:449:in render_serialized' lib/topic_list_responder.rb:16:in block (2 levels) in respond_with_list’
lib/topic_list_responder.rb:9:in respond_with_list' app/controllers/list_controller.rb:102:in block (2 levels) in class:ListController’
app/controllers/list_controller.rb:107:in public_send' app/controllers/list_controller.rb:107:in block (2 levels) in class:ListController’
app/controllers/application_controller.rb:340:in block in with_resolved_locale' app/controllers/application_controller.rb:340:in with_resolved_locale’
lib/middleware/omniauth_bypass_middleware.rb:68:in call' lib/content_security_policy/middleware.rb:12:in call’
lib/middleware/anonymous_cache.rb:336:in call' config/initializers/100-quiet_logger.rb:19:in call’
config/initializers/100-silence_logger.rb:31:in call' lib/middleware/enforce_hostname.rb:22:in call’
lib/middleware/request_tracker.rb:176:in `call’

Unfortunatly, go to safe mode and unactive everything d’ont resolve the problem.
I still have the error.

I have many many times this error in logs :

NoMethodError (undefined method hex' for nil:NilClass) app/models/upload.rb:180:in base62_sha1’ app/models/upload.rb:174:in short_path' app/models/upload.rb:146:in short_path’ app/models/group.rb:

And in the admin dashboard, some metrix ( Top Referred Topics ) give an error :
“sorry, request take too much time”

I have seen this once, the issue was that the category images were missing. Discourse tries to retrieve their dimensions and fails.

You might try to remove any category images.

I tried to restore but i have an error :

[2020-08-27 10:06:41] Pausing sidekiq…
[2020-08-27 10:06:41] Waiting up to 60 seconds for Sidekiq to finish running jobs…
[2020-08-27 10:38:40] EXCEPTION: ERROR: deadlock detected
DETAIL: Process 594 waits for AccessExclusiveLock on relation 1113165 of database 16569; blocked by process 1617.
Process 1617 waits for AccessShareLock on relation 1113221 of database 16569; blocked by process 594.
HINT: See server log for query details.
CONTEXT: SQL statement “ALTER TABLE public.categories SET SCHEMA backup;”
PL/pgSQL function inline_code_block line 11 at EXECUTE

We don’t have category image :frowning:

Hmm :thinking:
Group flair maybe?

how to know if the problem come from group flair and how to solve that ?
Thanks you very much

Try to remove or reupload the group avatar flair from any groups and see if it solves the issue.

That did it, @michaeld! Nice work. @Olivier_Baillon, you can mark Michael’s post as the solution!

If anyone else has this, you’d do something like:

cd /var/discourse
./launcher enter app
rails c
Group.all.pluck(:id,:flair_icon,:flair_upload_id)
# for the groups that have `flair_upload_id` something like
g=Group.find(GROUP_ID_FROM_THE_LIST) # that's id not flair_upload_id
g.flair_upload
g.save

There are more elegant ways, but if you have just a few this should get you started.

THANKS @michaeld and @pfaffman
I would never have found that myself.
Thanks you very much