Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4499

mongoc_server_description_handle_hello does not always set error when hello response is malformed

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.23.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible

      Summary

      When iterating through the hello response, mongoc_server_description_handle_hello does not set the bson_error_t on the server description if the type check on any fields fails. This causes further errors down the line due to _cluster_fetch_stream_single returning the server description's error if it selects a server with a type of MONGOC_SERVER_UNKNOWN. Since this error is not set, any operation that calls fails with an unknown error.

      Environment

      Versions starting with 1.22.0 are affected when connecting to a mongohoused. In my case, connecting to mongohoused returned a hello response which contained a connectionId with type int64, whereas libmongoc expects int32 for a connectionId.

      How to Reproduce

      The hello response that triggered this behaviour is as follows:

      { 
        "ok" : { "$numberInt" : "1" }, 
        "ismaster" : true, 
        "maxBsonObjectSize" : { "$numberInt" : "16777216" }, 
        "maxMessageSizeBytes" : { "$numberInt" : "48000000" }, 
        "maxWriteBatchSize" : { "$numberInt" : "100000" }, 
        "logicalSessionTimeoutMinutes" : { "$numberInt" : "30" }, 
        "connectionId" : { "$numberLong" : "565160423" }, 
        "minWireVersion" : { "$numberInt" : "0" }, 
        "maxWireVersion" : { "$numberInt" : "15" }, 
        "readOnly" : false 
      }
      

      Expected behaviour

      When setting the server description's type to unknown, the associated bson_error_t should contain a reason for why the server was marked as unknown. This is not the case for validation failures in the hello response.

            Assignee:
            gil.alon@mongodb.com Gil Alon
            Reporter:
            andreas.braun@mongodb.com Andreas Braun
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: