Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1063

mongocxx::uri doesn't validate URI on construction

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.3
    • Affects Version/s: 3.0.1
    • Component/s: Implementation
    • Labels:
      None

      Uncatchable Error during initialisation. try

      { . . . }catch(...){ . . . }

      If I input wrong input parameters like: "mongodb://:@:/" The my program exits with -1. Last output is: src/mongoc/mongoc-topology.c:155 mongoc_topology_new(): precondition failed: uri

      If the version of the new c++ driver is important, pleas tell me how I can find out the library version of my compiled libraries.

      CODE:
      mongocxx::client conn; // defined in class header file
      SomeClass::someClass(){
      std::stringstream stmMongoDbUri;
      stmMongoDbUri
      << "mongodb://" //<< MyConfiguration.dbUser
      << ":" //<< MyConfiguration.dbPassword
      << "@" //<< MyConfiguration.dbHost
      << ":" //<< MyConfiguration.dbPort
      << "/" //<< MyConfiguration.databaseName;

      std::string strMongoDbUri (std::istreambuf_iterator<char>(stmMongoDbUri), {});

      printf("47 - Streamconten Mongo DB Config > %s <", strMongoDbUri.c_str() );

      // src/mongoc/mongoc-topology.c:155 mongoc_topology_new(): precondition failed: uri
      // No valid connection established / invalid string... ka...
      //[strMongoDbUri] = "mongodb://:@:/"
      conn = mongocxx::client(mongocxx::uri(strMongoDbUri));
      ...
      }

            Assignee:
            david.golden@mongodb.com David Golden
            Reporter:
            Weltenbummler Armin Ball [X]
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: