luckyframework / luckyframework/avram
Invalid error throws exception rather than returning valid error back to user.
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I have a form with a date input. Passing a non date value e.g. "1" returns a suitable error back to the user. Entering "2019-22-22" (also an invalid date) results in an exception being thrown. I would expect the second input to return the same error back to the user as the first.
I believe the issue lies in ```time_extensions.cr``` specifically ```try_parsing_with_default_formatters```. This iterates through a series of format options (specified in ```TIME_FORMATS```) attempting to format the given date value. There is a try/catch block which expects a ```Time::Format::Error``` to be thrown if the conversion goes wrong. It looks like (to my untrained eye) that one of the formats (```Time::Format::ISO_8601_DATE```) doesn't appear to throw this exception.
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
Start in time_extensions.cr at try_parsing_with_default_formatters and inspect the TIME_FORMATS iteration, especially Time::Format::ISO_8601_DATE. Reproduce the inputs "1" and "2019-22-22"; done means both invalid dates return the expected user-facing error instead of allowing an exception to escape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100