Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-825

iso_string serde_helpers do not follow ISO-8601

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-2.0.0-beta.1
    • Affects Version/s: None
    • Component/s: BSON
    • None

      The bson_datetime_as_iso_string serde helper uses chrono::DateTime's Display functionality to produce a string, but this string is not properly ISO-8601 formatted. We should instead use DateTime::to_rfc3339 to explicitly ensure the output format of our strings. Likewise, the helpers that deserialize from strings use parse_str, which means non-ISO formatted strings will be deserialized when they should produce errors. We should restrict this by using parse_from_rfc3339.

      e.g. this test uses the following date, which is not valid according to either ISO-8601 or RFC 3339:

      1996-12-20 00:39:57 UTC
      

      I verified this doesn't match using Swift's ISO8601DateFormatter. 

      On a related note, we should update the names of these helpers to be more specific about which standard they're following to help avoid a similar issue from happening in the future. e.g. we could name the helper rfc3339_string_as_bson_datetime, since that will be the one we actually use from chrono.

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: