Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Details for BSON Deserialization Errors #435

Closed
clarkmcc opened this issue Oct 11, 2023 · 7 comments
Closed

Better Details for BSON Deserialization Errors #435

clarkmcc opened this issue Oct 11, 2023 · 7 comments
Assignees
Labels
tracked-in-jira Ticket filed in Mongo's Jira system

Comments

@clarkmcc
Copy link

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.

@abr-egn
Copy link
Contributor

abr-egn commented Oct 17, 2023

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.

@abr-egn abr-egn added tracked-in-jira Ticket filed in Mongo's Jira system and removed triage labels Oct 17, 2023
@clarkmcc
Copy link
Author

Thanks! Is it possible for me to somehow utilize dtolnay/path-to-error or would this need to be incorporated in this crate?

@jaredtmartin
Copy link

jaredtmartin commented Oct 24, 2023

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?

@bastibense
Copy link

Yes, please. The current errors are not very helpful at all and I had to trial-and-error myself through this.
Feels bad, man.

@clarkmcc
Copy link
Author

@jaredtmartin unfortunately I don't have a solution for this but yes, it's a real pain to deal with.

@omahili
Copy link

omahili commented Nov 11, 2024

This is extremely bad to work with, especially when you have tens of fields. It's basically impossible to find where the de-serialization error comes from. Very sad that nothing is being done about it.

@abr-egn
Copy link
Contributor

abr-egn commented Nov 11, 2024

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.

@abr-egn abr-egn closed this as completed Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracked-in-jira Ticket filed in Mongo's Jira system
Projects
None yet
Development

No branches or pull requests

5 participants