-
Notifications
You must be signed in to change notification settings - Fork 180
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
Error in datetime-regex #1260
Comments
I just realized that the regex is already correct in the XSD schemas - just not in the documentation. |
Thanks for calling that out. We have a triage sync tomorrow and I am sure we can address this sooner rather than later. |
I also noticed that all regexes were removed from the generated JSON schemas on 5/4/22 in 9a03286. I couldn't find a GitHub issue regarding this change, was this done on purpose? The JSON schemas previously also contained the incorrect regex. |
Not everyone uses Gregorian dates, so a string might be more appropriate. |
I am not 100% certain but I would imagine this was not done on purpose and this might have to do with updating the Metaschema submodule to address fixes usnistgov/metaschema#182. Will definitely look into this during triage later today! |
I think that there are strong reasons for enforcing the Internet date/time format (RFC 3339). It avoids much confusion and misunderstanding esp. when working with international partners. Conversion to different time zones and formats should not be a problem, as long as the stored value can be interpreted clearly. (As stated in the RFC: "because no date and time format is readable according to the conventions of all countries, Internet clients SHOULD be prepared to transform dates into a display format suitable for the locality.") |
I'm not sure that this fully closes this issue... I added a comment to the commit. |
…ex issues (usnistgov#1265) * Updated data type documentation to be consistent with schemas * Updated Metaschema toolchain to correct schema regex bugs. Resolves usnistgov#1260.
…ex issues (usnistgov#1265) * Updated data type documentation to be consistent with schemas * Updated Metaschema toolchain to correct schema regex bugs. Resolves usnistgov#1260.
Describe the bug
I believe there to be a bug in the "datetime with timezone" regex as described in
https://github.com/usnistgov/OSCAL/edit/main/docs/content/reference/datatypes.md
As it stands, the regex will match dates
2017-06-04T00:00:00Z
and1999-04-03T12:13:45Z
but it will NOT match i.e.2400-02-29T00:00:00Z
2022-05-03T02:00:00Z
.This is because the
T
separating the date from the time part of the regex is only applicable after the fourth of the major matching groups. There has to be an additional group containing the first three major blocks (the ones that are present to differentiate between leap years and normal years).I think to make the regex work like it's supposed to it needs to be this:
instead of the current
It becomes a bit clearer when you run it through a regex visualizer (using debuggex.com here):
Current regex (notice how T only matches for the last possible year-month-day pattern):
Corrected regex: (T matches after all possible variations of year-month-day):
Who is the bug affecting?
Anyone trying to use the regex pattern defined in the OSCAL (JSON) data types to determine if a date/date-time input is considered a valid date in the OSCAL format. (For instance I tripped over this bug because one of my entered dates was not accepted by an autogenerated REST API stub.)
What is affected by this bug?
See description above, only some valid dates will match the regex currently.
When does this occur?
The regex is present in the documentation, but it is also present in example content and generated OpenAPI specification. It is repeated 36 times in 9 files in the OSCAL repo (mostly XSD schemas)
How do we replicate the issue?
See above.
Expected behavior (i.e. solution)
See suggested change to the regex above.
Other Comments
The text was updated successfully, but these errors were encountered: