[GODRIVER-3081] Empty slice no longer encoding/decoding as nil in 1.13.0 and 1.12.2 Created: 02/Jan/24  Updated: 07/Feb/24  Resolved: 01/Feb/24

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 1.13.0, 1.12.2, 1.13.1
Fix Version/s: 1.13.2

Type: Bug Priority: Major - P3
Reporter: James Hartig Assignee: Qingyang Hu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test.go    
Issue Links:
Problem/Incident
is caused by GODRIVER-2914 Improvements in marshaling and compre... Closed
Related
Documentation Changes: Not Needed
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   

Detailed steps to reproduce the problem?

See attached test.go file. When inserting an empty slice, it would previously end up being decoded as nil but after GODRIVER-2914 and https://github.com/mongodb/mongo-go-driver/pull/1323 that now changed and it's now decoded as an empty slice.

test.go

Definition of done: what must be done to consider the task complete?

The Release Notes should be updated to denote this change in 1.13.x and an option should be added to restore the old behavior. It should be removed from 1.12.x as I believe it's a breaking change.

The exact Go version used, with patch level:

$ go version

This is happening with 1.22rc1 and 1.21.5.

The exact version of the Go driver used:

$ go list -m go.mongodb.org/mongo-driver

 

I tested with 1.31.0, 1.31.1, 1.12.0 and every commit in between to determine when it broke.

Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

N/A

The operating system and version (e.g. Windows 7, OSX 10.8, ...)

N/A

Security Vulnerabilities

If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here



 Comments   
Comment by Githook User [ 07/Feb/24 ]

Author:

{'name': 'Qingyang Hu', 'email': '103950869+qingyang-hu@users.noreply.github.com', 'username': 'qingyang-hu'}

Message: GODRIVER-3081 Fix zero value detection for empty slices and maps. (#1546)
Branch: v1
https://github.com/mongodb/mongo-go-driver/commit/4cb576df96d2d4beadc42c369e03f2ed29bbf510

Comment by Githook User [ 01/Feb/24 ]

Author:

{'name': 'Qingyang Hu', 'email': '103950869+qingyang-hu@users.noreply.github.com', 'username': 'qingyang-hu'}

Message: GODRIVER-3081 Fix zero value detection for empty slices and maps. (#1514)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/bdc38a6b3230d53c97c815004f22a7a656bf56a0

Comment by PM Bot [ 02/Jan/24 ]

Hi james@getadmiral.com, thank you for reporting this issue! The team will look into it and get back to you soon.

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