Can I get the document that generated a Deserialization error?

We have many applications written in Rust that use the latest MongoDB drivers, and everything has been working great.

We’re just migrating another application over to Rust, and the database that was in use previously has some issues with data quality.

When I now run a query, I’m getting deserialization issues for some documents. Ideally I’d like to be able to expost the _id that generated the deserialization issue. The log shows:

Error { kind: BsonDeserialization(DeserializationError { message: "invalid type: unit value, expected a string" }), labels: {}, wire_version: None, source: None }

I completely understand what is happening here, but I don’t know what field, or document that this error is related to. Some of these documents have hundreds of fields, and there are millions of documents, so exposing the _id and field that is the culprit would go a long way in helping to resolve the underlying data quality issue that we’re experiencing.

Is this possible to achieve?

For reference, the code that triggers the error:

    while let Some(result) = cursor.next().await {
        match result {
            Ok(document) => docs.push(document),
            Err(e) => {
                error!("Error retrieving document: {:?}", e);
            }
        }
    }

e doesn’t contain much help, unfortunely.

Thanks!