InvalidDocument clause does not include _id encoding

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 🔵 Done
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Our _dict_to_bson bson method contains this code block:

              for key, value in doc.items():
                  if not top_level or key != "_id":
                      try:
                          elements.append(_element_to_bson(key, value, check_keys, opts))
                      except InvalidDocument as err:
                          raise InvalidDocument(f"Invalid document: {err}", doc) from err
      

      We expected the try-except block to include encoding the _id field as well, but it explicitly does not.

      Definition of done

      Either determine why the code currently behaves this way or fix it to work as we expect.

      Pitfalls

      N/A.

            Assignee:
            Unassigned
            Reporter:
            Noah Stapp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: