Skip to content

fix(plugins): recover from reflection panics in templateSysData - #348

Open
AdamMagued wants to merge 1 commit into
mudler:masterfrom
AdamMagued:fix/issue-344-template-sysdata-panic
Open

AdamMagued wants to merge 1 commit into
mudler:masterfrom
AdamMagued:fix/issue-344-template-sysdata-panic

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #344

Problem

In pkg/plugins/common.go, templateSysData calls json.Marshal(&system). In certain environment states where sysinfo fields contain unexpected slice lengths or concurrent mutations, json.Marshal panics with reflect: slice index out of range, causing early initramfs failure during system boot.

Solution

  • Added a defensive defer recover() in templateSysData to catch unexpected reflection/marshalling panics, log a warning, and safely return the un-interpolated template string.
  • Added test coverage verifying that panic recovery behaves as expected.

Verified via container sandbox test suite.

Signed-off-by: Adam Magued <adamismailmageud@gmail.com>
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.

panic: reflect: slice index out of range in plugins.templateSysData

1 participant