Make IDL timestamp parsing more restrictive

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The IDL-defined timestamp and logicalTime types utilize BSONElement::timestamp for parsing, but this method is far too lenient with the types of inputs it accepts. For one, it will convert a BSON datetime (type 18) into a timestamp if the provided element is one. Secondly, if the element being parsed is neither a timestamp nor a datetime, a default-constructed timestamp is silently returned and no exception is thrown.

      We should update this parsing to be more strict, ideally to only support timestamps and to error if another type is found. Otherwise, this could easily lead to accidental bugs.

      notably, bsonExtractTimestamp has the desired behavior.

      As part of this, we should update the fields currently using timestamp in read_concern.idl to use logicalTime.

      See: https://github.com/10gen/mongo/blob/2d6caf003d5222bddc8c1606a539b6ca53f843bb/src/mongo/bson/bsonelement.h#L797

            Assignee:
            Unassigned
            Reporter:
            Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: