-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] 🐛 throw ParseException on invalid date #57968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hey! Thanks for your PR. You are targeting branch "7.2" but it seems your PR description refers to branch "7.2 for features / 5.4, 6.4, and 7.1 for bug fixes". Cheers! Carsonbot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some tests to prevent regressions
What does the YAML spec say about invalid date strings? Is the fallback to a plain string the expected behavior? |
I added a test. I do not know how far should I go with the "invalid dates"
I cannot seem to find anything searching https://yaml.org/spec/1.2.2/ for "date", "invalid", "incorrect". I also searched for "date" in https://github.com/yaml/yaml-test-suite without success. I tried with https://github.com/yaml/yaml-reference-parser/blob/main/parser-1.2/javascript (I had to hack a bit around to make it work) but it looks like this is not checking explicitly for dates: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://yaml-online-parser.appspot.com/?yaml=date%3A+2024-50-50&type=python yields an error for invalid date and I think we should do the same (i.e. throw a ParsException
).
I changed the code to an exception. Which branch should I target? 5.4? 6.4? 7.1? |
5.4 |
Done, There was a conflict on |
Can you please adjust the PR title and description? They don't match the implemented logic anymore. |
Done. Tests are failing on twig but I didn't change anything there. |
Thank you @homersimpsons. |
(found in symfony-tools/docs-builder#179)
When parsing the following yaml:
symfony/yaml
will throw an exception:This is because the "month" is invalid. Fixing the "month" will trigger about the same issue because the "day" would be invalid.
With the current change it will throw a
ParseException
.