Cakeday 在未经验证的用户进行 API 调用时崩溃

你好,

当我激活 cakeday 并且用户未登录时,我目前遇到了此错误:

    Message

    NoMethodError (undefined method user_option' for nil:NilClass) (eval):86:in _fast_attributes’
    app/serializers/post_stream_serializer_mixin.rb:54:in block in posts' app/serializers/post_stream_serializer_mixin.rb:47:in map’
    app/serializers/post_stream_serializer_mixin.rb:47:in posts' app/serializers/post_stream_serializer_mixin.rb:18:in post_stream’
    (eval):3:in _fast_attributes' app/controllers/application_controller.rb:545:in render_json_dump’
    app/controllers/topics_controller.rb:1249:in block (2 levels) in perform_show_response' app/controllers/topics_controller.rb:1239:in perform_show_response’
    app/controllers/topics_controller.rb:187:in show' app/controllers/application_controller.rb:414:in block in with_resolved_locale’
    app/controllers/application_controller.rb:414:in with_resolved_locale' lib/middleware/omniauth_bypass_middleware.rb:74:in call’
    lib/middleware/content_security_policy/middleware.rb:12:in call' lib/middleware/anonymous_cache.rb:367: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/discourse-cakeday/plugin.rb:68:in block (2 levels) in activate!' (eval):86:in _fast_attributes’
    /nix/store/jlw6xd3hvk4jdrp1aiiap9h62y13c7dj-ruby3.2.2-active_model_serializers-0.8.4/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.8.4/lib/active_model/serializer.rb:468:in rescue in attributes' /nix/store/jlw6xd3hvk4jdrp1aiiap9h62y13c7dj-ruby3.2.2-active_model_serializers-0.8.4/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.8.4/lib/active_model/serializer.rb:455:in attributes’
    /nix/store/jlw6xd3hvk4jdrp1aiiap9h62y13c7dj-ruby3.2.2-active_model_serializers-0.8.4/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.8.4/lib/active_model/serializer.rb:480:in _serializable_hash' /nix/store/jlw6xd3hvk4jdrp1aiiap9h62y13c7dj-ruby3.2.2-active_model_serializers-0.8.4/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.8.4/lib/active_model/serializer.rb:359:in serializable_hash’
    /nix/store/jlw6xd3hvk4jdrp1aiiap9h62y13c7dj-ruby3.2.2-active_model_serializers-0.8.4/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.8.4/lib/active_model/serializer.rb:347:in as_json' app/serializers/post_stream_serializer_mixin.rb:54:in block in posts’
    /nix/store/k92bjvqvynnbrvdd26vfg7cf5vh3dxhj-ruby3.2.2-activerecord-7.0.4.3/lib/ruby/gems/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/relation/delegation.rb:88:in each' /nix/store/k92bjvqvynnbrvdd26vfg7cf5vh3dxhj-ruby3.2.2-activerecord-7.0.4.3/lib/ruby/gems/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/relation/delegation.rb:88:in each’

    Env

    HTTP HOSTS: forum.miki.community

这似乎会导致 500 响应和一个“糟糕”的错误页面:/

你好 MTRNord :slight_smile:

我无法重现您的问题。您能描述一下精确的重现步骤吗?

我已经解决了这个问题,还没来得及更新,抱歉!问题是版本不兼容。:slight_smile: 更新到 3.2.0.beta1 后,它就能正常工作了。

2 个赞

此主题在 16 小时后自动关闭。不再允许回复。