[GODRIVER-1735] Operation construction does not return errors when responses are malformed Created: 31/Aug/20  Updated: 30/Mar/22

Status: Backlog
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.


Generated at Thu Feb 08 08:37:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.