Cakeday crashes at api call on unauthenticated users

Hi,

I am getting this error currently if I activate cakeday and the user isn’t logged in:



    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/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

It seems to cause a 500 response and an “Oops” error page :confused:

Hi MTRNord :slight_smile:

I can’t replicate your issue. Can you describe precise repro steps?

Actually I got it solved by now and didn’t get around to updating this yet, sorry! The issue was a version incompatibility. :slight_smile: Updating to 3.2.0.beta1 made it work correctly.

2 Likes

This topic was automatically closed after 16 hours. New replies are no longer allowed.