-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Unknown
-
None
-
Affects Version/s: 3.8.0
-
Component/s: Find - getMore - KillCursors
-
None
-
None
-
Rust Drivers
-
None
-
None
-
None
-
None
-
None
-
None
FindOptions::max_time serializes to an integer number of milliseconds via serialize_duration_option_as_int_millis, but it has no matching deserialize_with. Deserialization therefore falls back to the default serde representation of std::time::Duration and rejects the very value the driver itself emits:
invalid type: integer 5000, expected struct Duration
It only accepts { "secs": 5, "nanos": 0 }, an internal representation that no MongoDB document would ever carry.
Reproduction:
let options: FindOptions = bson::from_document(doc! { "maxTimeMS": 5000 }).unwrap();
Expected: max_time == Some(Duration::from_millis(5000))
Actual: deserialization fails with the error above
Every other option type in driver/src/coll/options.rs that carries max_time already applies deserialize_duration_option_from_u64_millis: AggregateOptions, CountOptions, DistinctOptions, EstimatedDocumentCountOptions, CreateIndexOptions, DropIndexOptions and ListIndexesOptions. FindOptions is the only one missing it.
The driver's own test suite shows the same expectation. driver/src/test/spec/unified_runner/operation/find.rs replicates the fields of FindOptions because serde cannot combine flatten with deny_unknown_fields, and it applies that helper to max_time by hand.
This reaches end users through Prisma, whose MongoDB connector deserializes the options argument of findRaw straight into FindOptions (from_bson::<FindOptions> in query-engine/connectors/mongodb-query-connector/src/root_queries/raw.rs). Passing { maxTimeMS: 25000 } to findRaw fails, while the identical value passed to aggregateRaw succeeds because AggregateOptions has the helper.
Reproduced on 3.8.0 and current main. I have a fix with tests ready and will open a pull request.