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

Exception "ValueError: unsupported format character" in _check_command_response

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 2.7.2
    • 2.8, 3.0
    • None
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: