[GODRIVER-538] The readpref.WithTags function is broken Created: 06/Sep/18  Updated: 28/Oct/23  Resolved: 06/Sep/18

Status: Closed
Project: Go Driver
Component/s: Options & Configuration
Affects Version/s: 0.0.12
Fix Version/s: 0.0.13

Type: Bug Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The readpref.WithTags function was entirely broken for any length of arguments n*2 where n > 1 or exactly 0 arguments.

0 arguments:
It only checked for length % 2 == 0 which a length of 0 obviously passes but that obviously isn't a legal tag.

Multiple of 2 arguments:
That for-loop was just completely wrong only accidentally being correct for exactly 2 tags.
It essentially made every key into a name and what should have been the next name into a key,
because it didn't skip any index but instead terminated at just half length, which also meant it would not include any actual later tags pairs.



 Comments   
Comment by Githook User [ 06/Sep/18 ]

Author:

{'name': 'Kris Brandow', 'email': 'kris@mongodb.com', 'username': 'skriptble'}

Message: Merge branch 'pr/87'

GODRIVER-538

Change-Id: I5ebe2e74b6f86a19e9d5ee05ee2d97bc0356fd85
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/771435c0c5ee0cd273776613602a2db60aa19502

Comment by Kristofer Brandow (Inactive) [ 06/Sep/18 ]

Pull Request: https://github.com/mongodb/mongo-go-driver/pull/87

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