Skip to content

Conversation

isabelatkinson
Copy link
Contributor

@isabelatkinson isabelatkinson commented Jun 27, 2025

This is the last of the conversions.

Self::DeserializationError {
message: err.to_string(),
}
fn from(error: serde_json::Error) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept this From impl in the public API because we're already exposing a bunch of serde_json conversions below. It might be worth putting all of the serde_json stuff behind the serde feature flag or giving it its own flag - if that makes sense I'll file a separate ticket.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense; I agree that putting the serde_json stuff behind its own feature flag would definitely be a good thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed RUST-2240

fn serialize_bool(self, v: bool) -> Result<Self::Ok> {
Err(Self::invalid_key(v))
fn serialize_bool(self, _v: bool) -> Result<Self::Ok> {
Err(Error::invalid_key_type("bool"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a deviation from the current API, which stores the invalid key as Bson. This leads to some weird placeholders (empty arrays and documents, Bson::Null if conversion fails). I think a string message that reports the bad type is sufficient here, and users can turn on serde_path_to_error for more detail.

@isabelatkinson isabelatkinson marked this pull request as ready for review June 27, 2025 17:18
@isabelatkinson isabelatkinson requested a review from a team as a code owner June 27, 2025 17:18
@isabelatkinson isabelatkinson requested a review from abr-egn June 27, 2025 17:18
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Self::DeserializationError {
message: err.to_string(),
}
fn from(error: serde_json::Error) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense; I agree that putting the serde_json stuff behind its own feature flag would definitely be a good thing.

@isabelatkinson isabelatkinson merged commit 431d448 into mongodb:main Jun 30, 2025
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants