Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
boeglid opened this issue Dec 17, 2021 · 0 comments · Fixed by #286
Closed

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

boeglid opened this issue Dec 17, 2021 · 0 comments · Fixed by #286

Comments

@boeglid
Copy link
Contributor

boeglid commented Dec 17, 2021

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)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant