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