Skip to content

Fix exception in NetworkManagerSettings.get_connections_by_id #77

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

Merged

Conversation

hkhateb
Copy link
Contributor

@hkhateb hkhateb commented Aug 22, 2025

Previously, calling get_connections_by_id could raise the following exception:

    settings_paths = await nm_settings.get_connections_by_id("eth0")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../networkmanager/objects.py", line 177, in get_connections_by_id
    settings_properties = await settings.get_settings()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../dbus_proxy_async_method.py", line 108, in _dbus_async_call
    reply_message = await bus.call_async(call_message)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sdbus.dbus_exceptions.DbusServiceUnknownError: The name org.freedesktop.NetworkManager was not provided by any .service files

This exception was discovered with the following test code:

import asyncio
from sdbus import sd_bus_open_system
from sdbus_async.networkmanager import NetworkManagerSettings

async def test_get_connections_by_id():
    system_bus = sd_bus_open_system()
    nm_settings = NetworkManagerSettings(system_bus)
    settings_paths = await nm_settings.get_connections_by_id("eth0")
    print(settings_paths)

if __name__ == "__main__":
    asyncio.run(test_get_connections_by_id())

After this fix, the issue is resolved and get_connections_by_id works correctly without raising an exception.

@igo95862
Copy link
Collaborator

igo95862 commented Aug 22, 2025

Hello @hkhateb

Thank you for submitting this PR.

Could I ask you to add some changes?

First, please name the commit something like Fix NetworkManagerSettings.get_connections_by_id not using the bus it was initialized with. The Fix exception is very generic and does not tell what exactly was fixed. Also change the description explaining the existing bug where the get_connections_by_id does not work properly with explicitly passed bus.

… was initialized with

The get_connections_by_id does not work properly with explicitly passed bus, and raises the following exception:

    settings_paths = await nm_settings.get_connections_by_id("eth0")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../networkmanager/objects.py", line 177, in get_connections_by_id
    settings_properties = await settings.get_settings()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../dbus_proxy_async_method.py", line 108, in _dbus_async_call
    reply_message = await bus.call_async(call_message)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sdbus.dbus_exceptions.DbusServiceUnknownError: The name org.freedesktop.NetworkManager was not provided by any .service files

This exception was discovered with the following test code:

import asyncio
from sdbus import sd_bus_open_system
from sdbus_async.networkmanager import NetworkManagerSettings

async def test_get_connections_by_id():
    system_bus = sd_bus_open_system()
    nm_settings = NetworkManagerSettings(system_bus)
    settings_paths = await nm_settings.get_connections_by_id("eth0")
    print(settings_paths)

if __name__ == "__main__":
    asyncio.run(test_get_connections_by_id())

After this fix, the issue is resolved and get_connections_by_id works correctly without raising an exception.
@hkhateb
Copy link
Contributor Author

hkhateb commented Aug 23, 2025

Hello @igo95862 I changed the title and the description as you asked

@hkhateb hkhateb force-pushed the fix_get_connections_by_id_exception branch from 6ffa188 to 4b94e8f Compare August 23, 2025 12:46
@igo95862 igo95862 merged commit 5f480c6 into python-sdbus:master Aug 23, 2025
@igo95862
Copy link
Collaborator

Thank you!

@hkhateb
Copy link
Contributor Author

hkhateb commented Aug 23, 2025 via email

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.

2 participants