psych
psych copied to clipboard
Dates with 5 digit years can not deserialized
require 'time'
require 'yaml'
date = DateTime.parse('22018-01-05')
serialized_date = YAML.dump(date)
YAML.load(serialized_date)
# => fails with NoMethodError: undefined method `captures' for nil:NilClass
This is because the regex for parsing a Date, in ScalarScanner, expects a 4 digit year.
The year is actually incorrect and should have been validated before being saved. It has made it in to our data.
Please close if you think this is too much of an edge case to be considered.
On the other hand 5 digit years are legit.
Hi @krisleech, I think the issue is on Line number 112 but here your mentioned Line number 113.