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

db.command({bulkwrite: 1, ...}) throws because 1 is not iterable

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.12, 4.11.2
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Not Needed

      Detailed steps to reproduce the problem?

      c = MongoClient()
      c.admin.command({"bulkWrite": 1, "nsInfo": "test.test", "ops": []})

       

      https://github.com/mongodb/mongo-python-driver/blob/c9a85ad321f98caf314fc9da7a367e94d661abac/pymongo/message.py#L411 here we use a map to find the "docs" for the command

      https://github.com/mongodb/mongo-python-driver/blob/c9a85ad321f98caf314fc9da7a367e94d661abac/pymongo/message.py#L108 this map says its bulkWrite which might be for some internal way of representing legacy bulkWrite commands cause I think the value in this map needs to be ops

      Definition of done: what must be done to consider the task complete?

      you should be able to manually run a multi namespace bulkWrite without using the helper. command() should handle any valid command. for now I'm just going to use the helper

      The exact Python version used, with patch level:

      3.10.12

      The exact version of PyMongo used, with patch level:

      Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import pymongo
      >>> print(pymongo.has_c())
      True
      >>> print(pymongo.version)
      4.11
      >>>

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      local 3 shard cluster

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      arm virtual work station

      Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, ...)

      locust

      Security Vulnerabilities

      If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            mickey.winters@mongodb.com Mickey Winters
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: