Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't serialize ROS as YAML #69

Open
aramgre opened this issue Nov 20, 2020 · 0 comments
Open

Can't serialize ROS as YAML #69

aramgre opened this issue Nov 20, 2020 · 0 comments

Comments

@aramgre
Copy link

aramgre commented Nov 20, 2020

Ruby 2.7.1
recursive-open-struct 1.1.3
YAML 3.1.0

Deserializing a ROS from YAML does not work. I think this is because YAML/Psych calls respond_to_missing? before the object is fully loaded, see similar issue in stripe-ruby gem stripe/stripe-ruby@8bb6acf

irb(main):001:0> require 'recursive-open-struct'
=> true
irb(main):002:0> require 'yaml'
=> true
irb(main):003:0> ros = RecursiveOpenStruct.new({x: 1})
irb(main):004:0> yaml = YAML.dump(ros)
irb(main):005:0> YAML.load(yaml)
Traceback (most recent call last):
       16: from (irb):5
       15: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych.rb:279:in `load'
       14: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/nodes/node.rb:50:in `to_ruby'
       13: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:32:in `accept'
       12: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/visitor.rb:6:in `accept'
       11: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/visitor.rb:16:in `visit'
       10: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:313:in `visit_Psych_Nodes_Document'
        9: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:32:in `accept'
        8: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/visitor.rb:6:in `accept'
        7: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/visitor.rb:16:in `visit'
        6: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping'
        5: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:394:in `revive'
        4: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:401:in `init_with'
        3: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:401:in `respond_to?'
        2: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/recursive-open-struct-1.1.3/lib/recursive_open_struct.rb:105:in `respond_to_missing?'
        1: from /Users/aram/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/recursive-open-struct-1.1.3/lib/recursive_open_struct.rb:182:in `_get_key_from_table_'
NoMethodError (undefined method `has_key?' for nil:NilClass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant