0

can someone help me with this, I added wisper-sidekiq in my gemfile, and when I tried to broadcast event with async: true it is failing with error
Psych::DisallowedClass: Tried to load unspecified class: Listener::Studentlistener whereas if I set the async: false it is working fine

wisper-sidekiq version: 1.0 sidekiq-version: 6.5 rails version: 6.1

I tried setting async: false it is working fine, but when I set async: true it's not working

  • rails version: 6.1 yeah came across this yaml case. so How to fix this issue for latest versions. Could you please help me with it. – m.sahil Kumar Jun 23 '23 at 13:12

1 Answers1

0

Ruby uses the psych gem under the covers to deal with yaml. In later rails versions, the default is to NOT load arbitrary yaml without your approval.

Need to add an initializer to tell the psych yaml loader what is allowed...

Psych::ClassLoader::ALLOWED_PSYCH_CLASSES = [
                                              Listener::Studentlistener
                                            ]

module Psych
  class ClassLoader
    ALLOWED_PSYCH_CLASSES = [] unless defined? ALLOWED_PSYCH_CLASSES
    class Restricted < ClassLoader
      def initialize classes, symbols
        @classes = classes + Psych::ClassLoader::ALLOWED_PSYCH_CLASSES.map(&:to_s)
        @symbols = symbols
        super()
      end
    end
  end
end
dbugger
  • 15,868
  • 9
  • 31
  • 33
  • thanks, it's working now, could you please explain in brief as psych is not a gem what we are doing over here exactly, and if possible please provide a reference to psych. – m.sahil Kumar Jun 23 '23 at 18:23