[TINKERPOP-3276][gremlin-javascript] Reject out-of-range OffsetDateTime values#3549
Open
xiazcy wants to merge 2 commits into
Open
[TINKERPOP-3276][gremlin-javascript] Reject out-of-range OffsetDateTime values#3549xiazcy wants to merge 2 commits into
xiazcy wants to merge 2 commits into
Conversation
Validate the constructed Date in the GraphBinary and GraphSON OffsetDateTime readers and throw when it falls outside the range representable by a JavaScript Date, instead of silently returning an invalid Date. https://issues.apache.org/jira/browse/TINKERPOP-3276 Assisted-by: Kiro:Claude-Opus-4.8
Contributor
|
VOTE +1 |
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.
Summary
The
gremlin-javascriptOffsetDateTime deserializers constructed a nativeDatewithout validating the result. JavaScript'sDatehas a much narrower range than Gremlin/JVM date-time types, so extreme boundary values (e.g. years near ±999999999, orOffsetDateTime.MAX/MIN) producedNaN. Becausenew Date(NaN)does not throw, deserialization appeared to succeed but returned an unusableDate:Both readers now detect that condition and fail deserialization with a clear error, so unsupported boundary values are rejected up front rather than silently becoming invalid
Dateinstances — consistent with how other unsupported values are handled.Changes
internals/OffsetDateTimeSerializer.js): after building theDatefrom the wire fields, throw ifNumber.isNaN(v.getTime()).type-serializers.js): the same guard inOffsetDateTimeSerializer.deserialize, for parity.OffsetDateTimeSerializer-test.js(GraphBinary) covering normal round-trips and boundary rejection for ±999999999.gx:OffsetDateTimeround-trip and boundary rejection for expanded-year ISO strings.VOTE +1