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

Exception "ValueError: unsupported format character" in _check_command_response

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.7.2
    • Fix Version/s: 2.8, 3.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      Python Sprint 8

      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

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: