[GODRIVER-854] Err: cannot transform type bson.D to a BSON Document Created: 27/Feb/19  Updated: 27/Oct/23  Resolved: 08/Mar/19

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

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

Issue Links:
Related
is related to GODRIVER-1194 Confusing error using uninitialized b... Closed

 Description   

As part of mgo->go driver migration, I found weird failures in evg: 
https://evergreen.mongodb.com/version/5c75aecd2fbabe2eb0b55062 . 
more specifically the error: 

Err: cannot transform type bson.D to a BSON Document: WriteArray can only write a Array while positioned on a Element or Value but is positioned on a TopLevel

The code caused this error: 
session.Database("admin").RunCommand(context.Background(), bson.D{{"buildInfo", int32(1)}}).Decode(&result)

(https://github.com/10gen/mms-backup/pull/317/commits/7b5323541e89a0fb77609ecdea9c99469f31e3af)

By changing bson.D{{"buildInfo", int32(1)}} to bson.M

{"buildInfo" : int32(1)}

the error went away. 

Can you please take a look? thanks!

Note: no mgo imported nor deps installed

 



 Comments   
Comment by Xiang Gao [ 07/Mar/19 ]

Ah I see. There's a bug in our EVG set up – we've been using 1.7. Thanks for the help! Good to close

Comment by Ian Whalen (Inactive) [ 04/Mar/19 ]

xiang.gao can you please ensure that your EVG env is correctly set up to use Go 1.10 or later?

Comment by Xiang Gao [ 28/Feb/19 ]

primitive.D works... 

Comment by Xiang Gao [ 27/Feb/19 ]

Also same code works fine in local env. running with go1.10, and go driver v1.0.0-rc1

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