-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Blocker - P1
-
None
-
Affects Version/s: 1.11.0, 1.10.4
-
Component/s: Connection String, Connections
-
Labels:
Summary
In topology.go (v1.11.0) line 239 connection string t.cfg.URI is parsed with generic url.Parse(...) instead of connstring.Parse(...)
If connection string contains Percent Encoded Password reports error (as example)
parse "mongodb+srv://user:test%2F%40": invalid port ":test%2F%40" after host
in func (t *Topology) Connect() error {...}
How to Reproduce
Is possible to reproduce using mongo Client Connect with a connection string with these characteristics
func TestURI(t *testing.T)
{ uri0 := "mongodb+srv://user:test%2F%40pwd@myatlasproject.mongodb.net/admin?retryWrites=true&w=majority" uri, err := url.Parse(uri0) // uri, err := connstring.Parse(uri0) assert.NoError(t, err) fmt.Println(uri) }Additional Background
I suggest replacing the command in topology.go [line 239 in function Connect()]
uri, err := url.Parse(t.cfg.URI)
with
uri, err := connstring.Parse(t.cfg.URI)
NOTE:
I have set the bug as a blocker because it does not allow me to keep the library up to date, but I don't know if it matches your priority criteria