fix ValueError exception when no disks are detected in the disk menu (#4598)

* Fix ValueError exception when no disks are detected in the disk menu

in lib/disk/disk_menu.py, the menu items are created using info from a list called "devices" (device_handler.devices). when no block devices are detected, the list is empty, creating zero MenuItems, and causing the following ValueError:

ValueError: Menu must have at least one item

this change checks if the length of the list is shorter than 1  (empty list) before constructing the menu. if the list is empty, the user will be notified that no disks were detected. otherwise, the menu is created and behaves as normal

* Fixed ruff formatting issue

* Fixed ruff formatting issue

---------

Co-authored-by: Anton Hvornum <torxed@archlinux.org>
This commit is contained in:
brurmonemt 2026-06-28 14:19:42 -05:00 committed by GitHub
parent 12f204571e
commit e4b2894db5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -311,6 +311,10 @@ async def select_devices(preset: list[BDevice] | None = []) -> list[BDevice] | N
devices = device_handler.devices devices = device_handler.devices
if len(devices) < 1:
await Notify(tr('No disks were detected. A disk is required to be able to install Arch Linux')).show()
return None
items = [ items = [
MenuItem( MenuItem(
str(d.device_info.path), str(d.device_info.path),