[GODRIVER-3044] Error when unmarshaling a BSON document if the document has unknown fields Created: 08/Nov/23  Updated: 08/Jan/24  Resolved: 08/Jan/24

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

Type: New Feature Priority: Unknown
Reporter: Matt Dale Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates GODRIVER-1121 Error when unmarshaling a BSON docume... Backlog
Documentation Changes Summary:

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?


 Description   

Context

Some users want the ability to configure a BSON decoder to return an error if the BSON document has fields that don't match fields in the decode destination struct. The Go "encoding/json" library supports a similar configuration called Decoder.DisallowUnknownFields . We should support something similar for the BSON decoder.

Definition of done

  • Add a configuration that causes decoding to return an error if there are fields in the decoded BSON document that don't match fields in the decode destination struct. Note that this only makes sense when the destination is a struct.
  • Add the ability to configure that unmarshal behavior on a MongoDB Client using BSONOptions.

Pitfalls

  • Adds additional configuration to the bson.Decoder type, which already has a lot of configurable behaviors.

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