Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4789

MongoUrlBuilder builds urls with invalid query string format

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.21.0
    • None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      Summary

      The MongoUrlBuilder creates a query string with incorrect separators - ';' instead of '&'.

      Driver version 2.21.0

      How to Reproduce

      Create a new .NET console app with top-level statements and paste the following:

      using System;
      using MongoDB.Driver;
      using MongoDB.Driver.Core.Configuration;
       
      var builder = new MongoUrlBuilder();
       
      builder.Scheme = ConnectionStringScheme.MongoDB;
      builder.Server = new MongoServerAddress("myserver");
       
      builder.Username = "user";
      builder.Password = "password";
       
      builder.AuthenticationMechanism = "DEFAULT";
      builder.AuthenticationSource = "mydatabase";
       
      Console.WriteLine(builder.ToMongoUrl()); 

      Expected output: 

      mongodb://user:password@myserver/?authMechanism=DEFAULT&authSource=mydatabase

      Actual output: 

      mongodb://user:password@myserver/?authMechanism=DEFAULT;authSource=mydatabase

      If I paste the actual output into e.g. Compass, it gives an error indicating that DEFAULT;authSource=mydatabase is not a valid value for authMechanism.

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

      Attachments

        Activity

          People

            adelin.mbidaowona@mongodb.com Adelin Mbida Owona
            jim.paton@computershare.co.uk Jim Paton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: