Skip to content

Conversation

isabelatkinson
Copy link
Contributor

@isabelatkinson isabelatkinson commented Sep 22, 2025

@isabelatkinson isabelatkinson marked this pull request as ready for review September 24, 2025 17:56
@isabelatkinson isabelatkinson requested a review from a team as a code owner September 24, 2025 17:56
src/error.rs Outdated
#[source]
pub(crate) source: Option<Box<Error>>,

pub(crate) server_response: Option<Box<Document>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd lean towards storing and exposing this as a RawDocumentBuf - this feels like a "lower level" API where the wire representation is more appropriate, and also it allows inspecting the bytes in case the server sends a response that doesn't fully parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - I updated this to be a raw document. I did leave the tracing representation to be a parsed document for readability in logs (https://github.com/mongodb/specifications/blob/master/source/logging/logging.md#representing-documents-in-log-messages) with a hex string of the byte vec as a fallback.

fn tracing_representation(&self) -> String {
self.to_string()
impl crate::error::Error {
fn tracing_representation(&self, max_document_length: usize) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Having to feature-conditionally thread this through everywhere is a bit unpleasant; what would you think about attaching max_document_length as a field of Error instead?

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 prefer this approach as it'll accommodate any future additions of fields needing truncation for the conection and SDAM emitters, and it feels consistent with other fields for the command emitter - happy to make the change if you feel strongly in the other direction, though

@isabelatkinson isabelatkinson merged commit d6689bb into mongodb:main Oct 3, 2025
17 of 20 checks passed
@isabelatkinson isabelatkinson deleted the raw-result branch October 3, 2025 14:44
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