Skip to content

Server fails with: "error dbus.Store: type mismatch" since release 5.0.4  #285

@boeglid

Description

@boeglid

The issue was introduced with the update from 5.0.3. to 5.0.4.

Setup: Dbus server with some properties of type slice, e.g.:

MyDbusProp: {
			Value:    []model.MyProp{},
			Writable: true,
			Emit:     prop.EmitTrue,
			Callback: func(c *prop.Change) *dbus.Error {
				return nil
			},
		},

On setting the property from server side the following error occurs: error dbus.Store: type mismatch: slice: cannot convert a value of []model.MyProp into []model.MyProp

Patching the the isConvertbileTo function seemd to solve the issue, see the patched function below:

dbus/dbus.go

Line 116 in e92e1d8

func isConvertibleTo(dest, src reflect.Type) bool {

func isConvertibleTo(dest, src reflect.Type) bool {
	switch {
	case isVariant(dest):
		return true
	case dest.Kind() == reflect.Interface:
		return true
	case dest.Kind() == reflect.Slice:
		return src.Kind() == reflect.Slice &&
			isConvertibleTo(dest.Elem(), src.Elem())
	case dest.Kind() == reflect.Struct:
		// return dest.Kind() == src.Kind()
		return src == interfacesType || dest.Kind() == src.Kind()
	default:
		return src.ConvertibleTo(dest)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions