js-bson - PR #909: fix: use the first instant of year 10000 as the relaxed EJSON date bound

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • bson-7.3.2
    • Affects Version/s: None
    • Component/s: None
    • 2
    • 2
    • Not Needed
    • None
    • Hide

      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.

      Show
      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      spokodev has created [PR #909: fix: use the first instant of year 10000 as the relaxed
      EJSON date bound|https://github.com/mongodb/js-bson/pull/909] in js-bson

      Actual vs Expected behavior

      EJSON.stringify({ a: new Date(253402300800000) }, { relaxed: true })
      // {"a":{"$date":"+010000-01-01T00:00:00Z"}}   invalid 6-digit-year ISO
      // should be {"a":{"$date":{"$numberLong":"253402300800000"}}}

      Use Case

      As a user of js-bson
      I want EJSON serialization to choose the correct type for value serialization when using dates
      So that the server does not reject bson dates sourced from deserialized ejson.

      User Experience

      • Today: If a user serializes a document to ejson, dates which breach the 10k year threshold (bson-corpus spec) by up to 5 hours should be encoded as a number. Today, they are encoded as a date. Theoretically, if these are somehow serialized into bson, they will fail to be passed to the server as these dates are not supported:
        Not all database operations and drivers support the full 64-bit range. You may safely work with dates with years within the inclusive range 0 through 9999.

        Expected Behaviour: the 'inRange' type switching behaviour should be tightened to align with the bson-corpus spec, disallowing dates >9999 years.

      Dependencies

      • N/A

      Risks/Unknowns

      • Potentially a breaking change. If users routinely send large integers through here as a date that satisfy the narrow range (10k+years + 5hrs), they will see a change in behaviour

      Acceptance Criteria

      Implementation Requirements

      • Ensure the boundary date value returns a valid date encoding in EJSON.stringify

      Testing Requirements

      • Regression test for the bound

      Documentation Requirements

      • Release note crediting the user

      Follow Up Requirements

      • N/A

       

       

            Assignee:
            Pavel Safronov
            Reporter:
            TPM Jira Automations Bot
            Pavel Safronov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: