-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 1.0.2
-
Component/s: Connections
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
- backported by
-
GODRIVER-1106 Backport "Allow specifying empty value for connection URI readPreferenceTags option"
- Closed