[GODRIVER-1797] Undefined attribute that is an array fails completing unmarshal Created: 17/Nov/20  Updated: 09/Dec/20  Resolved: 09/Dec/20

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

Type: Bug Priority: Major - P3
Reporter: Tyson Henry Assignee: Benji Rewis (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File codec2_test.go    
Issue Links:
Duplicate
duplicates GODRIVER-1235 Extended JSON can fail to parse if un... Closed
Related
is related to GODRIVER-1235 Extended JSON can fail to parse if un... Closed

 Description   

similar to issue https://jira.mongodb.org/browse/GODRIVER-1235

However, if the json document contains a field that is not defined in the struct and that field happens to be an array, the Skip() call on line 284 os struct_codec.go reads all the way to the end of document (EOD) and the DecodeValue() returns, it doesn't continue parsing the other fields in the document.  Attached is a series of tests that show the behavior.  I don't see any struct flags and or other flags to change this behavior. 

If an undefined field is a primitive (string, int, etc), the parser works fine.  If the  undefined field is another struct/map the parser works fine.



 Comments   
Comment by Benji Rewis (Inactive) [ 09/Dec/20 ]

This bug has been fixed in doing GODRIVER-1235. Embedded arrays and objects in undefined fields were not being skipped correctly during extended JSON unmarshalling.

Comment by Divjot Arora (Inactive) [ 02/Dec/20 ]

Moving back to Scheduled as we've increased the scope of GODRIVER-1235. Once that's done, we'll come back to this and see if it's still a problem.

Comment by Benji Rewis (Inactive) [ 02/Dec/20 ]

https://github.com/mongodb/mongo-go-driver/pull/548

Comment by Kevin Albertson [ 19/Nov/20 ]

Hi tyson.henry@burstiq.com, thank you for the bug report (and the helpful test). I was able to reproduce this with the test you provided. The team will decide when to schedule this soon.

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