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

Interface not found: DBus::Error instead of nil (and then NoMethodError) #74

Merged
merged 1 commit into from
Apr 30, 2018

Conversation

mvidner
Copy link
Owner

@mvidner mvidner commented Mar 26, 2018

No description provided.

@mvidner
Copy link
Owner Author

mvidner commented Mar 26, 2018

@aschnell this is a fix for one of the things you reported

@aschnell
Copy link

LGTM except for the testsuite issues.

The example below would be correct if it said
`unit_o["org.freedesktop.systemd1.Unit"]`.

With the wrong interface name, `unit_i` used to become `nil` and you
would get an unhelpful
"NoMethodError: undefined method `[]' for nil:NilClass" later.

With this fix, it raises
"DBus::Error: no such interface `Unit' on object `/org/freedesktop/systemd1/unit/_2d_2emount'"

```rb
bus = DBus::SystemBus.instance
svc = bus.service("org.freedesktop.systemd1")
unit_o = svc["/org/freedesktop/systemd1/unit/_2d_2emount"]
unit_i = unit_o["Unit"]  # BUG
descr = unit_i["Description"]
```
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 88.283% when pulling 794f3cc on unknown-interface into d702d98 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 88.283% when pulling 794f3cc on unknown-interface into d702d98 on master.

@coveralls
Copy link

coveralls commented Apr 30, 2018

Coverage Status

Coverage increased (+0.02%) to 87.992% when pulling 794f3cc on unknown-interface into d702d98 on master.

@mvidner mvidner merged commit 45220d4 into master Apr 30, 2018
@mvidner mvidner deleted the unknown-interface branch April 30, 2018 14:18
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Jan 25, 2021
https://build.opensuse.org/request/show/865300
by user coolo + dimstar_suse
- 0.16.0
 API:
 * An invalid service name or an invalid object path will raise
   instead of being sent to the bus. The bus would then drop the
   connection, producing EOFError here (gh#mvidner/ruby-dbus#80).

- 0.15.0
 API:
 * Accessing an unknown interface will raise instead of
   returning nil (gh#mvidner/ruby-dbus#74).
 Bug fixes:
 * Fixed a conflict with activesupport 5.2 (gh#mvidner/ruby-dbus#71)
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 this pull request may close these issues.

3 participants