重装应用后无法登录,出现500错误

它显示:

糟糕

驱动此讨论论坛的软件遇到了意外问题。我们对由此带来的不便深表歉意。

错误详情已记录,并生成了自动通知。我们会进行查看。

无需进一步操作。但是,如果错误状况持续存在,您可以通过在站点的反馈类别中发布讨论主题来提供更多详细信息,包括重现错误的步骤。

日志中:

info

NoMethodError (undefined method `keys' for nil:NilClass)
(eval):76:in `_fast_attributes'
app/controllers/application_controller.rb:650:in `preload_current_user_data'
app/controllers/application_controller.rb:445:in `preload_json'
app/controllers/application_controller.rb:421:in `block in with_resolved_locale'
app/controllers/application_controller.rb:421:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
config/initializers/008-rack-cors.rb:24:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:228:in `call'

backtrace

plugins/chat/lib/chat/channel_fetcher.rb:164:in `preload_custom_fields_for'
plugins/chat/lib/chat/channel_fetcher.rb:159:in `secured_public_channels'
plugins/chat/lib/chat/channel_fetcher.rb:9:in `structured'
plugins/chat/plugin.rb:239:in `block (2 levels) in activate!'
(eval):76:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:347:in `as_json'
activesupport (7.0.5.1) lib/active_support/json/encoding.rb:22:in `encode'
activesupport (7.0.5.1) lib/active_support/json/encoding.rb:22:in `encode'
activesupport (7.0.5.1) lib/active_support/core_ext/object/json.rb:42:in `to_json'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:331:in `to_json'
multi_json (1.15.0) lib/multi_json/adapters/oj.rb:56:in `dump'
multi_json (1.15.0) lib/multi_json/adapters/oj.rb:56:in `dump'
multi_json (1.15.0) lib/multi_json/adapter.rb:25:in `dump'
multi_json (1.15.0) lib/multi_json.rb:139:in `dump'
app/controllers/application_controller.rb:650:in `preload_current_user_data'
app/controllers/application_controller.rb:445:in `preload_json'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:400:in `block in make_lambda'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:199:in `block (2 levels) in halting'
actionpack (7.0.5.1) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:200:in `block in halting'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:595:in `block in invoke_before'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:595:in `each'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:595:in `invoke_before'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:116:in `block in run_callbacks'
app/controllers/application_controller.rb:421:in `block in with_resolved_locale'
i18n (1.14.1) lib/i18n.rb:322:in `with_locale'
app/controllers/application_controller.rb:421:in `with_resolved_locale'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.5.1) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.5.1) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.5.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.5.1) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.5.1) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.5.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.5.1) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.5.1) lib/action_view/rendering.rb:39:in `process'
rack-mini-profiler (3.1.0) lib/mini_profiler/profiling_methods.rb:85:in `block in profile_method'
actionpack (7.0.5.1) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.5.1) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
actionpack (7.0.5.1) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:852:in `call'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
rack (2.2.8) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.8) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.8) lib/rack/head.rb:12:in `call'
actionpack (7.0.5.1) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
config/initializers/008-rack-cors.rb:24:in `call'
rack (2.2.8) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.8) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/cookies.rb:704:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.5.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
logster (2.12.2) lib/logster/middleware/reporter.rb:43:in `call'
railties (7.0.5.1) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.5.1) lib/rails/rack/logger.rb:27:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
rack (2.2.8) lib/rack/method_override.rb:24:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (2.2.8) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/host_authorization.rb:131:in `call'
rack-mini-profiler (3.1.0) lib/mini_profiler.rb:260:in `call'
message_bus (4.3.7) lib/message_bus/rack/middleware.rb:60:in `call'
lib/middleware/request_tracker.rb:228:in `call'
railties (7.0.5.1) lib/rails/engine.rb:530:in `call'
railties (7.0.5.1) lib/rails/railtie.rb:226:in `public_send'
railties (7.0.5.1) lib/rails/railtie.rb:226:in `method_missing'
rack (2.2.8) lib/rack/urlmap.rb:74:in `block in call'
rack (2.2.8) lib/rack/urlmap.rb:58:in `each'
rack (2.2.8) lib/rack/urlmap.rb:58:in `call'
unicorn (6.1.0) lib/unicorn/http_server.rb:634:in `process_client'
unicorn (6.1.0) lib/unicorn/http_server.rb:739:in `worker_loop'
unicorn (6.1.0) lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn (6.1.0) lib/unicorn/http_server.rb:143:in `start'
unicorn (6.1.0) bin/unicorn:128:in `<top (required)>'
vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'

env

hostname	iosre-app
process_id	226
application_version	497d5b4ca04794612509e43674aeba8aabb669e3
HTTP_HOST	iosre.com
REQUEST_URI	/
REQUEST_METHOD	GET
HTTP_USER_AGENT	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
HTTP_ACCEPT	text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
HTTP_REFERER	https://iosre.com/
HTTP_X_FORWARDED_FOR	115.171.177.163, 192.168.0.1
HTTP_X_REAL_IP	192.168.0.1
username	snakeninny
time	11:09 pm

有什么想法吗?谢谢!

即使在安全模式下也是如此

如果禁用了插件页面上的 discourse chat,它会消失吗?

您安装了哪些插件?

我甚至无法登录……我无法进入插件页面
app.yml 中已安装插件的列表:

- git clone https://github.com/discourse/docker_manager.git
- git clone https://github.com/discourse/discourse-solved.git
- git clone https://github.com/discourse/discourse-reactions.git
- git clone https://github.com/discourse/discourse-spoiler-alert.git
- git clone https://github.com/discourse/discourse-akismet.git
- git clone https://github.com/discourse/discourse-feature-voting
- git clone https://github.com/discourse/discourse-data-explorer.git
- git clone https://github.com/discourse/discourse-apple-auth.git
- git clone https://github.com/discourse/discourse-follow.git
- git clone https://github.com/discourse/discourse-cakeday.git
- git clone https://github.com/discourse/discourse-bcc.git
- git clone https://github.com/paviliondev/discourse-landing-pages.git

/var/www/discourse/plugins 中的插件列表:

root@iosre-app:/var/www/discourse/plugins# ls -al
total 96
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:02 .
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 ..
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 chat
drwxr-xr-x 12 discourse root      4096 Jan  7 03:07 discourse-akismet
drwxr-xr-x  7 discourse root      4096 Jan  7 03:07 discourse-apple-auth
drwxr-xr-x  9 discourse root      4096 Jan  7 03:07 discourse-bcc
drwxr-xr-x  9 discourse root      4096 Jan  7 03:07 discourse-cakeday
drwxr-xr-x 11 discourse root      4096 Jan  7 03:07 discourse-data-explorer
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 discourse-details
drwxr-xr-x 11 discourse root      4096 Jan  7 03:07 discourse-feature-voting
drwxr-xr-x 12 discourse root      4096 Jan  7 03:07 discourse-follow
drwxr-xr-x 13 discourse root      4096 Jan  7 03:02 discourse-landing-pages
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 discourse-lazy-videos
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 discourse-local-dates
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 discourse-narrative-bot
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 discourse-presence
drwxr-xr-x 11 discourse root      4096 Jan  7 03:07 discourse-reactions
drwxr-xr-x 10 discourse root      4096 Jan  7 03:07 discourse-solved
drwxr-xr-x  8 discourse root      4096 Jan  7 03:07 discourse-spoiler-alert
drwxr-xr-x 12 discourse root      4096 Jan  7 03:02 docker_manager
drwxr-xr-x  2 discourse root      4096 Jan  7 03:02 plugins
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 poll
drwxr-xr-x  1 discourse discourse 4096 Jan  7 03:01 styleguide

尝试在没有展馆插件的情况下重新构建

不带 paviliondev

- git clone https://github.com/discourse/docker_manager.git
- git clone https://github.com/discourse/discourse-solved.git
- git clone https://github.com/discourse/discourse-reactions.git
- git clone https://github.com/discourse/discourse-spoiler-alert.git
- git clone https://github.com/discourse/discourse-akismet.git
- git clone https://github.com/discourse/discourse-feature-voting
- git clone https://github.com/discourse/discourse-data-explorer.git
- git clone https://github.com/discourse/discourse-apple-auth.git
- git clone https://github.com/discourse/discourse-follow.git
- git clone https://github.com/discourse/discourse-cakeday.git
- git clone https://github.com/discourse/discourse-bcc.git
# - git clone https://github.com/paviliondev/discourse-landing-pages.git

重建后,错误 500 仍然存在。
奇怪的是这次安全模式没有帮到我。在 backtrace 中我注意到了 chat,这会不会是 chat 的 bug?我该如何暂时禁用 chat 插件来测试?

这次我重建了应用程序,移除了大部分插件:

- git clone https://github.com/discourse/docker_manager.git
# - git clone https://github.com/discourse/discourse-solved.git
# - git clone https://github.com/discourse/discourse-reactions.git
# - git clone https://github.com/discourse/discourse-spoiler-alert.git
# - git clone https://github.com/discourse/discourse-akismet.git
# - git clone https://github.com/discourse/discourse-feature-voting
# - git clone https://github.com/discourse/discourse-data-explorer.git
# - git clone https://github.com/discourse/discourse-apple-auth.git
# - git clone https://github.com/discourse/discourse-follow.git
# - git clone https://github.com/discourse/discourse-cakeday.git
# - git clone https://github.com/discourse/discourse-bcc.git
# - git clone https://github.com/paviliondev/discourse-landing-pages.git

仍然是同样的问题

这感觉像是与聊天有关……你能试试吗?

./mothership enter ...
rails c
SiteSetting.chat_enabled = false
1 个赞

谢谢!是 chat

(base) root@iosre:/var/discourse# ./launcher enter app
检测到 x86_64 架构。
root@iosre-app:/var/www/discourse# rails c
插件名称是 'discourse-topic-voting',但插件目录名为 'discourse-feature-voting'
[1] pry(main)> SiteSetting.chat_enabled = false
=> false

在此之后,没有 500 错误,我可以进入页面

我们需要弄清楚聊天中发生了什么导致了这个错误,这与频道配置有关。
至少我们可以在 channel_fetcher 中添加一些保护措施,以确保它不会像这样崩溃。

1 个赞

谢谢!有什么可以帮您的吗?

还没有,聊天团队本周会查看,会通知您!

4 个赞

一样,在稳定版上。
我怀疑这个已在此修复 FIX: Preload the right fields on categories (#24396) · discourse/discourse@0bc568f · GitHub
你运行的是什么版本 @snakeninny

1 个赞

啊,谢谢,我曾怀疑这与我们的分类工作有关,但无法证实。错误完全发生在分类预加载中,所以这说得通。

然而,根据 OP:

所以很可能是在修复之后 :confused:

1 个赞

啊,我错过了。

但那个提交是在修复之前!它的日期是 11 月 9 日,而修复是在 11 月 15 日完成的。

是的,确实如此,我认为我弄混了链接,所以问题99%出在这里。

如果你能更新的话,请尝试一下@snakeninny

谢谢@RGJ :chefs_kiss:

4 个赞

:warning: 此问题出现在论坛从 3.1.3 更新到 3.1.4 时。
我们正在调查导致此问题的原因,一旦有更多信息,我们将立即通知您。

5 个赞

是的,问题在于上述的修复没有被移植到稳定版,但稳定版现在依赖于它。

@j.jaffeux @daniel 请紧急将此移植到稳定版好吗?目前,当启用聊天时,稳定版对于任何已登录用户来说都完全无法使用。

2 个赞

是的,请帮我一下,我遇到了同样的错误,我的网站也崩溃了,我还在等待 communiteq 的回复。