Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1078

Allow specifying empty value for connection URI readPreferenceTags option

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.0.3
    • Affects Version/s: 1.0.2
    • Component/s: Connections
    • Labels:

      Specifying readPreferenceTags without a value via connection string will receive an error :

      panic: error parsing uri (mongodb+srv://USER:PWD@cluster-test.mongodb.net/admin?ssl=true&retryWrites=true&readPreference=secondary&readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=): invalid value for readPreferenceTags: 
      

      Currently the workaround is specify via option as below example:

      tags := []map[string]string{map[string]string{"dc": "ny", "rack": "1" }, 
                                  map[string]string{ "dc": "ny" }, 
                                  map[string]string{}}
      tagSets := tag.NewTagSetsFromMaps(tags)
      readPrefOption := []readpref.Option{readpref.WithTagSets(tagSets...)}
      readPreference, err := readpref.New(readpref.Secondary().Mode(), readPrefOption...)
      if err != nil {
          panic(err)
      }
      opts := options.Client().ApplyURI(mongoURI).SetReadPreference(readPreference)
      client, err := mongo.NewClient(opts)
      if err != nil {
          panic(err)
      }
      

      Reference - list value in connection string spec : https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst#values

            Assignee:
            manny.eppinger@mongodb.com Emmanuel Eppinger (Inactive)
            Reporter:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: