MongoUrlBuilder builds urls with invalid query string format

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.21.0
    • Component/s: None
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      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.

              Assignee:
              Adelin Mbida Owona
              Reporter:
              Jim Paton
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: