sync receive_message raises ValueError instead of ProtocolError for OP_COMPRESSED messages with 16 < length ≤ 25

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • 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

      receive_message (sync path) is missing the OP_COMPRESSED minimum-length guard that exists in the async PyMongoProtocol.process_header.

      PyMongoProtocol.process_header has the correct guard:

      if op_code == 2012:
          if length <= 25:
              raise ProtocolError(
                  f"Message length ({length!r}) not longer than standard OP_COMPRESSED message header size (25)"
              )

      Definition of done

      Add the same guard to receive_message before entering the op_code == 2012 branch:

      if op_code == 2012:
          if length <= 25:
              raise ProtocolError(
                  f"Message length ({length!r}) not longer than standard OP_COMPRESSED message header size (25)"
              )
          ...

      Pitfalls

      NA

            Assignee:
            Alex Clark
            Reporter:
            Alex Clark
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: