Skip to content

Commit

Permalink
Protect against exceptions when getting properties from udev
Browse files Browse the repository at this point in the history
We've seen online UnicodeDecodeErrors from pyudev, but let's just
catch all exceptions here and try to process the device anyway.

Fixes: #490
  • Loading branch information
vojtechtrefny committed Jan 17, 2025
1 parent 28da4a0 commit 5c559a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion blivet/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def device_to_dict(device):
# Sice blivet uses Device.properties only (with couple of exceptions)
# this is a functional workaround. (japokorn May 2017)

result = dict(device.properties)
result = dict()
for key in device.properties.keys():
try:
result[key] = device.properties.get(key)
except Exception as e: # pylint: disable=broad-except
log.error("Failed to get %s property of %s: %s", key, device.sys_name, str(e))
result["SYS_NAME"] = device.sys_name
result["SYS_PATH"] = device.sys_path
return result
Expand Down

0 comments on commit 5c559a8

Please sign in to comment.