ruby/psych

Mapping key limit gives confusing error message.

Opened this issue · 0 comments

Apparently keys over 1022 characters are not supported:

> key = 'n' * 3
 => "nnn"
> text = "\"#{key}\": 12"
 => "\"nnn\": 12"
> YAML.load(text)
 => {"nnn"=>12}

> key = 'n' * 1023
=> "nnnnnnn..."
> text = "\"#{key}\": 12"
 => "\"nnnnnn..."
> YAML.load(text)
Traceback (most recent call last):
        6: from /usr/local/rvm/rubies/ruby-2.5.3/bin/irb:11:in `<main>'
        5: from (irb):53
        4: from /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/psych.rb:263:in `load'
        3: from /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/psych.rb:350:in `parse'
        2: from /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/psych.rb:402:in `parse_stream'
        1: from /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/psych.rb:402:in `parse'
Psych::SyntaxError ((<unknown>): mapping values are not allowed in this context at line 1 column 1026)

the "mapping values are not allowed" is not a clear error message for this situation.