Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1608

CosmosDB local emulator connection string not parsed properly

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Connection Mgmt
    • None

      The connection string for azure cosmosdb emulator is the following:

      mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true

      But it seems like pymongo is not parsing it properly.

      Here's my code:

      import pymodm
      CONN_STR = "mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true"
      pymodm.connection.connect(CONN_STR)

      And I get this error:

      Traceback (most recent call last):
      {{ File "test.py", line 3, in <module>}}
      {{ pymodm.connection.connect(CONN_STR)}}
      {{ File "....virtualenvs\env-YN3\lib\site-packages\pymodm\connection.py", line 63, in connect}}
      {{ parsed_uri = uri_parser.parse_uri(mongodb_uri)}}
      {{ File "....virtualenvs\env-YN3\lib\site-packages\pymongo\uri_parser.py", line 424, in parse_uri}}
      {{ nodes = split_hosts(hosts, default_port=default_port)}}
      {{ File "....virtualenvs\env-YN3\lib\site-packages\pymongo\uri_parser.py", line 260, in split_hosts}}
      {{ nodes.append(parse_host(entity, port))}}
      {{ File "....virtualenvs\env-YN3\lib\site-packages\pymongo\uri_parser.py", line 155, in parse_host}}
      {{ % (port,))}}
      ValueError: Port must be an integer between 0 and 65535: C2y6yDjf5

       

      It does work whenever I specify the username and password directly, though, so it appears to be a problem with the pymongo connection string parser. The following code works fine:
      host = "mongodb://localhost:10255/cm?ssl=true"
      user = "localhost"
      password = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
      pymodm.connection.connect(host, username=user, password=password)

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            epicfaace Ashwin Ramaswami
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: