Project

General

Profile

Actions

Bug #11966

closed

YAML#load fails with OpenStruct object

Added by brianstorti (Brian Storti) almost 9 years ago. Updated over 8 years ago.

Status:
Closed
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 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #11884: Psych.load broken for OpenStruct in Ruby 2.3.0Closedmarcandre (Marc-Andre Lafortune)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0