Uploaded image for project: 'Mender'
  1. Mender
  2. MEN-2801

Research why official mongo-go driver needs the following patch

    XMLWordPrintable

    Details

    • Type: Knowledge acquisition
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:

      Description

      with the new mongo driver (https://github.com/mendersoftware/inventory/pull/141) you can see an error:

      panic: interface conversion: interface {} is primitive.A, not []interface {} 

      which is "not true":

      # grep -rnH 'type A ' /go/
      /go/src/go.mongodb.org/mongo-driver/bson/bson.go:60:type A = primitive.A
      /go/src/go.mongodb.org/mongo-driver/bson/bson_1_8.go:71:type A []interface{}
      /go/src/go.mongodb.org/mongo-driver/bson/primitive/primitive.go:206:type A []interface{} 

      it is some strange thing, but this patch fixes it:

      diff --git a/bson/bsoncodec/default_value_decoders.go b/bson/bsoncodec/default_value_decoders.go
      index 65cd1c0..ce17aa7 100644
      --- a/bson/bsoncodec/default_value_decoders.go
      +++ b/bson/bsoncodec/default_value_decoders.go
      @@ -83,7 +83,7 @@ func (dvd DefaultValueDecoders) RegisterDefaultDecoders(rb *RegistryBuilder) {
                      RegisterDefaultDecoder(reflect.Ptr, NewPointerCodec()).
                      RegisterTypeMapEntry(bsontype.Double, tFloat64).
                      RegisterTypeMapEntry(bsontype.String, tString).
      -               RegisterTypeMapEntry(bsontype.Array, tA).
      +               RegisterTypeMapEntry(bsontype.Array, reflect.TypeOf([]interface{}{})).
                      RegisterTypeMapEntry(bsontype.Binary, tBinary).
                      RegisterTypeMapEntry(bsontype.Undefined, tUndefined).
                      RegisterTypeMapEntry(bsontype.ObjectID, tOID). 

      it seems that tA is not defined at this point, or some other type-definition loop is made. This needs investigation before men-2454 and men-2453 can be closed.

        Attachments

          Activity

            People

            • Assignee:
              merlin Peter Grzybowski
              Reporter:
              merlin Peter Grzybowski
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel