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

DateTimes with large distance to epoch panic

    • 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
    • Labels:

      Attempting to deserialize a BSON datetime with a large number of milliseconds from epoch can result in a panic, as per the chrono docs: https://docs.rs/chrono/0.4.19/chrono/offset/trait.TimeZone.html#method.timestamp_millis.

      We should fix this to return an error rather than panicking.

      repro:

      let json = json!({ "d": { "$date": { "$numberLong": i64::MAX.to_string() } } });
      let d = serde_json::from_value::<Document>(json);
      println!("{:?}", d);

      yields:

      thread 'main' panicked at 'No such local time', /home/patrick/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/offset/mod.rs:173:34
      

       

            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: