[GODRIVER-1980] BSON Type 0x00 (document) missing Created: 23/Apr/21 Updated: 27/Oct/23 Resolved: 10/May/21 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 1.5.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Mike Dotson | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux |
||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Documentation Changes Summary: | May need to include new Document type in the godoc. |
||||
| Description |
|
bsontype.go does not include `0x00` for top level document types per the bsonspec.org. This can be seen when using `UnmarshalBSONValue` to determine the document type. Attached code to duplicate the issue. |
| Comments |
| Comment by Isabella Siu (Inactive) [ 26/Apr/21 ] |
|
Hi again mike.dotson@its-broke.com! The main reason that we don't have a value for top-level document is because the documentation doesn't include it on either the MongoDB docs or bsonspec.org. The top-level document doesn't have an identifying byte, as the 0x00 byte on the bsonspec is a null-terminal. A bsontype represent the type value for a key/value pair. |
| Comment by Mike Dotson [ 26/Apr/21 ] |
|
Hi @Isabella Siu, I actually don't know that it's a BSON document, hence the checks. If it's not a `bsontype.EmbeddedDocument` or (in this case `\x00`, ie `bsontype.Document`?) I fail the marshaling without the need to process the bytes to find it's not something that will result in a valid unmarshal (ie, single double that should result as a map[string]int64) I also have other types that are unmarshaled based off of types such as `bsontype.Null`, `bsontype.Int32`, `bsontype.Int64`, etc. that work as expected. Having the go driver return "invalid" string for a valid document seems a bit off and definitely makes the code look a bit awkward when reading and seeing this odd `\x00` check. Look forward to the conclusion on the 0x00 type.
Thanks. |
| Comment by Isabella Siu (Inactive) [ 26/Apr/21 ] |
|
If you know that the type that you're unmarshaling is a BSON document, we recommend implementing UnmarshalBSON instead. We're still discussing what to do with the 0x00 type, and will update this ticket when when we come to a conclusion. |
| Comment by Mike Dotson [ 23/Apr/21 ] |
|
output from code:
|