Skip to content

Commit f7ec61b

Browse files
committed
minor: don't invariant() on invalid connection string options
1 parent 2db6676 commit f7ec61b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mongo/client/dbclient.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ namespace mongo {
319319
boost::algorithm::split(
320320
optionsTokens, optionsMatch, boost::algorithm::is_any_of("=&"));
321321

322-
invariant(optionsTokens.size() % 2 == 0);
322+
if (optionsTokens.size() % 2 != 0) {
323+
errmsg = "Missing a key or value in the options for mongodb:// URL: " + url;
324+
return ConnectionString();
325+
}
323326

324327
for (size_t i = 0; i != optionsTokens.size(); i = i + 2)
325328
options[std::string(optionsTokens[i].begin(), optionsTokens[i].end())] =

0 commit comments

Comments
 (0)