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

bson.errors.InvalidDocument key must not contain '.'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 3.6.1
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      None
    • Environment:
    • Case:

      Description

      When importing data into mongo using pymongo and .insert, it would fail with the error:
      bson.errors.InvalidDocument: key <REDACTED> must not contain '.'

      If we added check_keys=False to the .insert, it would allow the data to continue to be imported:
      collection.insert(json.loads(mongo_record),check_keys=False)

      However when we swapped to using .insertmany, there is no check_keys=False option to be passed:
      collection.insert_many(mongo_records,ordered=False,bypass_document_validation=True)

      Traceback:

      {{Traceback (most recent call last):
        File "../../fetch2.py", line 264, in <module>
          main()
        File "../../fetch2.py", line 255, in main
          collection.insert_many(mongo_records,ordered=False,bypass_document_validation=True)
        File "/usr/local/lib/python3.5/dist-packages/pymongo/collection.py", line 742, in insert_many
          blk.execute(self.write_concern.document, session=session)
        File "/usr/local/lib/python3.5/dist-packages/pymongo/bulk.py", line 432, in execute
          return self.execute_command(generator, write_concern, session)
        File "/usr/local/lib/python3.5/dist-packages/pymongo/bulk.py", line 323, in execute_command
          self.is_retryable, retryable_bulk, s, self)
        File "/usr/local/lib/python3.5/dist-packages/pymongo/mongo_client.py", line 1079, in _retry_with_session
          return func(session, sock_info, retryable)
        File "/usr/local/lib/python3.5/dist-packages/pymongo/bulk.py", line 318, in retryable_bulk
          retryable, full_result)
        File "/usr/local/lib/python3.5/dist-packages/pymongo/bulk.py", line 278, in _execute_command
          self.collection.codec_options, bwc)
      bson.errors.InvalidDocument: key <REDACTED> must not contain '.'}}
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              behackett Bernie Hackett
              Reporter:
              eoin.miller Eoin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: