Better Details for BSON Deserialization Errors
When I get a BSON deserialization error, it looks something like this
invalid type: unit value, expected a sequence
Is it possible to have the error contain more helpful information, like the path or something like that? I've been stomping out little deserialization issues for the last several months, and it's tricky to figure out exactly what set it off.
We recognize that the current error messages aren't great; unfortunately, the way serde is set up makes it tricky to include path or other source location. This is definitely on our roadmap, though - you can follow https://jira.mongodb.org/browse/RUST-1246 for updates.
Thanks! Is it possible for me to somehow utilize dtolnay/path-to-error or would this need to be incorporated in this crate?
I'm in the same situation. I like your idea @clarkmcc of using dtolnay/path-to-error. Have you figured out how to implement it? If not have you found any other solution/workaround?
Yes, please. The current errors are not very helpful at all and I had to trial-and-error myself through this. Feels bad, man.
@jaredtmartin unfortunately I don't have a solution for this but yes, it's a real pain to deal with.
Sorry, we apparently forgot to update here! If you enable the serde_path_to_error feature of the bson crate you'll get deserialization errors that include the full path to the field. This isn't enabled by default because it comes with a small runtime cost.