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

Properly validate bson document size when creating a RawBSONDocument

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.8
    • Affects Version/s: 3.4, 3.5, 3.6, 3.7
    • Component/s: BSON
    • None
    • Minor Change

      This regression was added in PYTHON-1106.

      PyMongo 3.2:

      >>> r = RawBSONDocument(BSON.encode({}))
      >>> r['f']
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "bson/raw_bson.py", line 77, in __getitem__
          return self.__inflated[item]
      KeyError: 'f'
      

      PyMongo 3.4-3.7:

      >>> from bson.raw_bson import RawBSONDocument
      >>> r = RawBSONDocument(BSON.encode({}))
      >>> r['f']
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "bson/raw_bson.py", line 83, in __getitem__
          return self.__inflated[item]
        File "bson/raw_bson.py", line 79, in __inflated
          raise InvalidBSON('bad object or element length')
      bson.errors.InvalidBSON: bad object or element length
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: