test(format/date-time): add high-precision second fraction as valid#962
Open
vtushar06 wants to merge 1 commit into
Open
test(format/date-time): add high-precision second fraction as valid#962vtushar06 wants to merge 1 commit into
vtushar06 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new format: "date-time" conformance test to ensure validators accept RFC 3339 second fractions with sufficiently high precision (15 fractional digits), helping catch implementations that incorrectly coerce seconds into IEEE-754 floats and mis-handle boundary rounding.
Changes:
- Added a valid
date-timeinstance with a 15-digit fractional second (1985-04-12T00:59:59.999999999999999Z) to each supported test suite variant (draft3/4/6/7 optional, draft2019-09 optional, draft2020-12 optional, and v1). - Ensures consistent coverage across all existing
tests/**/format/date-time.jsonfiles in the repository.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/v1/format/date-time.json | Adds a new valid high-precision fractional-second date-time test case. |
| tests/draft7/optional/format/date-time.json | Adds the same valid high-precision fractional-second date-time test case. |
| tests/draft6/optional/format/date-time.json | Adds the same valid high-precision fractional-second date-time test case. |
| tests/draft4/optional/format/date-time.json | Adds the same valid high-precision fractional-second date-time test case. |
| tests/draft3/optional/format/date-time.json | Adds the same valid high-precision fractional-second date-time test case. |
| tests/draft2020-12/optional/format/date-time.json | Adds the same valid high-precision fractional-second date-time test case. |
| tests/draft2019-09/optional/format/date-time.json | Adds the same valid high-precision fractional-second date-time test case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following the methodology I used for ipv4 and uuid, I read RFC 3339 section 5.6 and found the suite has no date-time test for a second fraction long enough to expose the float-coercion bound in a real validator.
RFC 3339 section 5.6 defines
time-secfrac = "." 1*DIGIT- the fraction is unbounded, any number of digits is valid.1985-04-12T00:59:59.999999999999999Z(second 59, fifteen 9s) is therefore valid. This exercises the boundary a validator hits if it coerces the seconds field to a float: fifteen 9s is the smallest count that rounds59.999...up to exactly60.0.Changes
1985-04-12T00:59:59.999999999999999Z- a valid second fraction of fifteen 9s - valid.Ecosystem Impact
sec = Number("59." + fifteen 9s), which is60.0exactly (IEEE-754; the gap between representable doubles at 60 is 2^-47), sosec < 60is false and it falls into the leap-second branch, which needs UTC hour 23 - at hour 00 it rejects a valid input. This is the defaultaddFormats(ajv)mode; ajv-fast (pure regex) accepts it. Fourteen 9s (the control) stays below 60.0 and is accepted.is_rfc3339_datetime: PASSES (accepts it).RFC References
time-secfrac = "." 1*DIGIT): https://www.rfc-editor.org/rfc/rfc3339#section-5.6Reproduction and the date-time cross-implementation matrix are in my evidence repo: https://github.com/vtushar06/JSON-Schema-format-test-Evidence/blob/main/date-time.md
Related: #965