Skip to content

Fix: Avoid a hard panic and use a recoverable error instead#307

Merged
cgwalters merged 1 commit into
composefs:mainfrom
henrywang:fix-no-initramfs-panic
Jun 5, 2026
Merged

Fix: Avoid a hard panic and use a recoverable error instead#307
cgwalters merged 1 commit into
composefs:mainfrom
henrywang:fix-no-initramfs-panic

Conversation

@henrywang
Copy link
Copy Markdown
Contributor

Issue: Arch Linux container build where pacman -Syu in a downstream stage installs a newer kernel version
(with nativevmlinuz in /usr/lib/modules/<kver>/) but no corresponding initramfs.

UsrLibModulesVmlinuz::load_all calls self.initramfs.unwrap() which panics instead of returning an error when a kernel directory has vmlinuz but no initramfs

fix: change unwrap() to ok_or_else(|| anyhow!("no initramfs for kernel {kver}")) and propagate

Two tests:

  • test_into_type1_with_initramfs — verifies the right path produces entries with the correct vmlinuz and initramfs
  • test_into_type1_without_initramfs_returns_error — verifies None initramfs returns an error containing "no initramfs" rather than panic

Johan-Liebert1
Johan-Liebert1 previously approved these changes Jun 5, 2026
Copy link
Copy Markdown
Collaborator

@Johan-Liebert1 Johan-Liebert1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this

@Johan-Liebert1 Johan-Liebert1 enabled auto-merge June 5, 2026 04:27
@Johan-Liebert1
Copy link
Copy Markdown
Collaborator

Needs cargo fmt

Issue: Arch Linux container build where pacman -Syu in a
downstream stage installs a newer kernel version
(with nativevmlinuz in /usr/lib/modules/<kver>/) but no
corresponding initramfs.

UsrLibModulesVmlinuz::load_all calls self.initramfs.unwrap() which
panics instead of returning an error when a kernel directory has
vmlinuz but no initramfs

fix: change unwrap() to ok_or_else(|| anyhow!("no initramfs for
kernel {kver}")) and propagate

Two tests:
- test_into_type1_with_initramfs — verifies the right path produces
entries with the correct vmlinuz and initramfs
- test_into_type1_without_initramfs_returns_error — verifies None
initramfs returns an error containing "no initramfs" rather than
panic

Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
auto-merge was automatically disabled June 5, 2026 05:44

Head branch was pushed to by a user without write access

@henrywang henrywang force-pushed the fix-no-initramfs-panic branch from f7470e4 to 0857e8b Compare June 5, 2026 05:44
@Johan-Liebert1 Johan-Liebert1 enabled auto-merge June 5, 2026 05:51
@Johan-Liebert1 Johan-Liebert1 added this pull request to the merge queue Jun 5, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 5, 2026
@cgwalters cgwalters added this pull request to the merge queue Jun 5, 2026
Merged via the queue into composefs:main with commit 4c3e68f Jun 5, 2026
19 of 34 checks passed
@henrywang henrywang deleted the fix-no-initramfs-panic branch June 5, 2026 13:05
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