Dates with 5 digit years can not deserialized
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 597
- Forks
- 223
- Avg merge
- 11h 23m
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the Ruby snippet in the issue, then inspect lib/psych/scalar_scanner.rb around the Date regex at line 113. Confirm how a five-digit year is parsed and define completion as successfully loading the dumped DateTime without the captures error, while preserving valid date handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100