Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
1.0.2
Description
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
Attachments
Issue Links
- backported by
-
GODRIVER-1106 Backport "Allow specifying empty value for connection URI readPreferenceTags option"
-
- Closed
-