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

Failure to parse hello response from server #1024

Closed
yourlogarithm opened this issue Feb 6, 2024 · 3 comments
Closed

Failure to parse hello response from server #1024

yourlogarithm opened this issue Feb 6, 2024 · 3 comments
Assignees

Comments

@yourlogarithm
Copy link

yourlogarithm commented Feb 6, 2024

Versions/Environment

  1. What version of Rust are you using?

    • rustc 1.77.0-nightly (5d3d3479d 2024-01-23)
  2. What operating system are you using?

    • System: Arch Linux
    • Kernel: Linux 6.7.3-arch1-2
    • Architecture: x86-64
    • Hardware Vendor: Dell Inc.
    • Hardware Model: Latitude 5531
  3. What versions of the driver and its dependencies are you using?

  4. What version of MongoDB are you using? (Check with the MongoDB shell using db.version())

    • 4.4.12
  5. What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?

    • replica set

Describe the bug

connectionId expected to be i64 but is Double

To Reproduce

  1. 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()),
      },
  }
}
  1. 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))
}
  1. 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), ... }))
@abr-egn
Copy link
Contributor

abr-egn commented Feb 6, 2024

Thank you for the detailed bug report! I'm looking into this now.

@abr-egn
Copy link
Contributor

abr-egn commented Feb 6, 2024

I've reproduced this locally; we'll have a fix out shortly and will cut a patch release to include it.

@abr-egn
Copy link
Contributor

abr-egn commented Feb 9, 2024

We just released version 2.8.1 of the driver which fixes this issue. Again, thanks for the report!

@abr-egn abr-egn closed this as completed Feb 9, 2024
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

No branches or pull requests

2 participants