Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1735

Operation construction does not return errors when responses are malformed

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      Many of our operations construct responses and set a local err variable if a response field is not properly formatted or do not match the types we expect for them, but then return nil, effectively swallowing the error. See https://github.com/mongodb/mongo-go-driver/blob/1aa08c501f4c34674d933b317d8830e0d9eeeddc/x/mongo/driver/operation/update.go#L61 for an example.

      When we do this, we should also confirm that we're reading fields from server responses correctly. For example, we expect the value field in a findAndModify response to always be a document, but it can actually be a BSON null value if the filter did not match any documents in the collection. This currently works as expected because we're ignoring the error set at https://github.com/mongodb/mongo-go-driver/blob/1aa08c501f4c34674d933b317d8830e0d9eeeddc/x/mongo/driver/operation/find_and_modify.go#L81, but this logic will have to be updated to fallback to NullOK if DocumentOK fails and only set an error if both fail.

      Attachments

        Activity

          People

            Unassigned Unassigned
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: