Project

General

Profile

Bug #11966

YAML#load fails with OpenStruct object

Added by brianstorti (Brian Storti) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290)
[ruby-core:72761]

Description

Code that can be used to reproduce the issue (works on 2.2.3, fails on 2.3.0):

require 'ostruct'
require 'yaml'

yaml = "
args:
- !ruby/object:OpenStruct
  table:
    :body: foo "

YAML.load(yaml)

Stacktrace:

/opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/ostruct.rb:176:in `respond_to_missing?': undefined method `key?' for nil:NilClass (NoMethodError)
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `respond_to?'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `init_with'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:374:in `revive'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:330:in `block in register_empty'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:330:in `each'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:330:in `register_empty'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:141:in `visit_Psych_Nodes_Sequence'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:338:in `block in revive_hash'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:336:in `each'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:336:in `each_slice'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:336:in `revive_hash'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:162:in `visit_Psych_Nodes_Mapping'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:311:in `visit_Psych_Nodes_Document'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/nodes/node.rb:38:in `to_ruby'
    from /opt/boxen/rbenv/versions/2.3.0/lib/ruby/2.3.0/psych.rb:253:in `load'
    from ostruct.rb:10:in `<main>'

Related issues

Is duplicate of Ruby master - Bug #11884: Psych.load broken for OpenStruct in Ruby 2.3.0ClosedActions

History

#1

Updated by marcandre (Marc-Andre Lafortune) over 3 years ago

  • Is duplicate of Bug #11884: Psych.load broken for OpenStruct in Ruby 2.3.0 added

Updated by marcandre (Marc-Andre Lafortune) over 3 years ago

  • Status changed from Open to Closed

Thanks for filing this. Already fixed, see #11884.

Updated by naruse (Yui NARUSE) over 3 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

Also available in: Atom PDF