Closed yourlogarithm closed 8 months ago
What version of Rust are you using?
What operating system are you using?
What versions of the driver and its dependencies are you using?
What version of MongoDB are you using? (Check with the MongoDB shell using db.version())
db.version()
What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
connectionId expected to be i64 but is Double
connectionId
i64
Double
To Reproduce
Modify this function for a more verbose error:
pub(crate) fn into_hello_reply(self) -> Result<HelloReply> { match self.body::<CommandResponse<HelloCommandResponse>>() { Ok(response) if response.is_success() => { let server_address = self.source_address().clone(); let cluster_time = response.cluster_time().cloned(); Ok(HelloReply { server_address, command_response: response.body, cluster_time, raw_command_response: self.into_raw_document_buf(), }) }, Ok(_) => { // Handle the case where the response is Ok but does not meet is_success condition Err(ErrorKind::InvalidResponse { message: String::from("The command response was not successful.") }.into()) }, Err(err0) => match self.body::<CommandResponse<CommandErrorBody>>() { Ok(command_error_body) => Err(Error::new( ErrorKind::Command(command_error_body.body.command_error), command_error_body.body.error_labels, )), Err(err1) => Err(ErrorKind::InvalidResponse { message: format!("invalid server response: {err0:?}\nbody: {:?}", self.raw.to_document()) } .into()), }, } }
Use this connection function
async fn get_db(var: &str, db_name: &str) -> Result<mongodb::Database, Box<dyn Error>> { let mut options = mongodb::options::ClientOptions::parse(env::var(var)?).await?; options.app_name = Some("meta-validator".to_string()); // println!("{:?}", options); let client = mongodb::Client::with_options(options)?; let databases = client.list_database_names(None, None).await?; debug!("Connected to {}: {:?}", db_name, databases); Ok(client.database(db_name)) }
Get the error:
Error { kind: InvalidResponse { message: \"invalid type: floating point `1162786981.0`, expected i64\" }, labels: {}, wire_version: None, source: None } body: Ok(Document({ ..., \"connectionId\": Double(1162786981.0), \"minWireVersion\": Int32(0), ... }))
Thank you for the detailed bug report! I'm looking into this now.
I've reproduced this locally; we'll have a fix out shortly and will cut a patch release to include it.
We just released version 2.8.1 of the driver which fixes this issue. Again, thanks for the report!
Versions/Environment
What version of Rust are you using?
What operating system are you using?
What versions of the driver and its dependencies are you using?
What version of MongoDB are you using? (Check with the MongoDB shell using
db.version()
)What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
Describe the bug
connectionId
expected to bei64
but isDouble
To Reproduce
Modify this function for a more verbose error:
Use this connection function
Get the error: