From the gridfs spec:
Note: drivers SHOULD store length as Int64 and chunkSize as Int32 when creating new GridFS files. However, drivers MUST be able to handle existing GridFS files where the length and chunkSize fields might have been stored using a different numeric data type.
However, the Go driver cannot handle existing GridFS files if the type of length (or chunkSize, presumably) is not int64.
To reproduce, insert some GridFS data using the python driver (which stores length as Int32) and try to read it with the Go driver. It will panic with output similar to this:
panic: Call of bsoncore.Value.Int64 on 32-bit integer type goroutine 1 [running]: github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/x/bsonx/bsoncore.Value.Int64(0x110, 0xc000300094, 0x4, 0x10c, 0x107) /Users/patrickfreed/go/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/x/bsonx/bsoncore/value.go:693 +0x18a github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson.RawValue.Int64(0x10, 0xc000300094, 0x4, 0x10c, 0x0, 0x1) /Users/patrickfreed/go/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson/raw_value.go:273 +0x66 github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/mongo/gridfs.(*Bucket).openDownloadStream(0xc000278000, 0x1526180, 0xc000238480, 0xc000107a38, 0x1, 0x1, 0x0, 0x0, 0x0) /Users/patrickfreed/go/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/mongo/gridfs/bucket.go:341 +0x347 github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/mongo/gridfs.(*Bucket).OpenDownloadStreamByName(0xc000278000, 0x7ffeefbff6e0, 0xc, 0x0, 0x0, 0x0, 0x23, 0xc000107cf0, 0x1) /Users/patrickfreed/go/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/mongo/gridfs/bucket.go:214 +0x41f
- backported by
-
GODRIVER-957 Backport "Go driver cannot decode gridfs files collection documents if the length field is not stored as int64"
- Closed
- is caused by
-
PYTHON-1738 Length field of gridfs files collection documents stored as Int32 instead of int64
- Closed
- is depended on by
-
TOOLS-1833 Migrate tools (excluding mongoreplay) to new Go Driver
- Development Complete