[Yaml] 🐛 throw ParseException on invalid date#57968
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 |
stof
left a comment
There was a problem hiding this comment.
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: |
xabbuh
left a comment
There was a problem hiding this comment.
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/yamlwill 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.