Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4706

Validate Timestamp t,i constructor values

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • bson-5.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 2
    • Not Needed
    • Not Needed

      Use Case

      See MONGOSH-1307. Adding validation to the Timestamp constructor would be a breaking change but it would be desirable to identify misconstructed timestamps.

      User Impact

      • Migration may requires code changes
        • Only users who have incorrectly built Timestamps would now be warned by the BSON library that there is an issue constructing the Timestamp instance

      Acceptance Criteria

      Implementation Requirements

      • Assert the t and i fields are positive and within uint32.max

      Testing Requirements

      • The error would be thrown to a direct caller, or during deserialization
        • Test both cases

      Remove two argument style ctor of Timestamp

      • Migration will require code changes
        • Any instance of new Timestamp(low: number, high: number) will need to be wrapped in Long construction or broken into the i, t style constructor.

      Acceptance Criteria

      Implementation Requirements

      • Remove support for the constructor overload that takes two plain numbers as input
      • Since removing support will likely lead to a runtime error (props not existing etc.) add a helpful error to be thrown if this usage is detected.

      Testing Requirements

      • Assert the constructor fails in the old usage case
      • Update any Timestamp tests to use the i, t style constructor

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: