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

Exception "ValueError: unsupported format character" in _check_command_response

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.8, 3.0
    • Affects Version/s: 2.7.2
    • Component/s: None
    • None

      Exception is raise when authenticate fails and user includes percent sign '%'.

      Example of code to reproduce the issue:

          from pymongo import MongoClient
          client = MongoClient("127.0.0.1")
          admin_db = client.admin
          admin_db.authenticate("abc%", "cba%")
      

      The problem line is https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/helpers.py#L178

         raise OperationFailure(msg % errmsg, code, response)
      

      In my case msg is "command SON ( [ ( 'authenticate', 1), ('user', u'abc%'), ('nonce', u'd8eec066dd2c61c0'), ('key', u'7e11b80df608cbc9a38d0403da9333f2')]) failed: %s"

      I.e. this string includes symbols %' which can be formatted by python. So escaping is needed.

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

              Created:
              Updated:
              Resolved: