ruby/psych

Nil tag with implicit: false raises error on SnakeYAML

headius opened this issue · 1 comments

The following line, when reached by the tests from #475, triggers SnakeYAML to raise an error:

register o, @emitter.start_mapping(nil, c.tag, c.implicit, c.style)

The error:

RuntimeError: org.yaml.snakeyaml.emitter.EmitterException: tag is not specified
                      scalar at org/jruby/ext/psych/PsychEmitter.java:206
    visit_Psych_Nodes_Scalar at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:32
                       visit at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:30
                      accept at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:6
   visit_Psych_Nodes_Mapping at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:43
                        each at org/jruby/RubyArray.java:1864
   visit_Psych_Nodes_Mapping at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:43
                       visit at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:30
                      accept at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:6
  visit_Psych_Nodes_Document at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:27
                        each at org/jruby/RubyArray.java:1864
  visit_Psych_Nodes_Document at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:27
                       visit at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:30
                      accept at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:6
    visit_Psych_Nodes_Stream at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:21
                        each at org/jruby/RubyArray.java:1864
    visit_Psych_Nodes_Stream at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/emitter.rb:21
                       visit at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:30
                      accept at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/visitors/visitor.rb:6
                        yaml at /Users/headius/projects/jruby/lib/ruby/stdlib/psych/nodes/node.rb:61
                        dump at /Users/headius/projects/jruby/lib/ruby/stdlib/psych.rb:515
                      <main> at blah.rb:13

As far as I can tell, the issue is that the tag is nil and implicit is false, which is prohibited in SnakeYAML for a mapping.

This is somewhat outside my understanding of YAML and I am not sure whether this constitutes an improper behavioral difference in SnakeYAML or not.

The implicit value comes from the default @implicit of Coder, and is never set to true in the logic hit by the tests mentioned above. As it stands I do not know how to reconcile the values being passed in with the SnakeYAML hard error.

This leads to the remaining failures in jruby/jruby#6680, which I will exclude to proceed with the Psych update.

@headius do you need any support here or the issue is closed ?