Repository navigation
fix(plugins): recover from reflection panics in templateSysData - #348
Open
AdamMagued wants to merge 1 commit into
Open
AdamMagued wants to merge 1 commit into
AdamMagued wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new tests cannot compile because logger.NewDummy does not exist, and their missing-key assertion would fail without exercising the recovery branch.
2 open issues
What changed in this PR
This PR addresses #344 by containing system-info marshalling panics in templateSysData, preventing them from terminating boot-stage processing.
Changes:
- Recovers from marshalling panics, logs a warning, and returns the original template.
- Adds nil-logger guards to recovery-related warnings.
- Adds a test intended to verify template rendering and panic recovery.
| File | Description |
|---|---|
pkg/plugins/common.go |
Adds panic recovery and unchanged-template fallback around system-info marshalling. |
pkg/plugins/common_test.go |
Adds the intended rendering and recovery test. |
Review effort: Balanced
Comment on lines
+6
to
+11
| "github.com/mudler/yip/pkg/logger" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestTemplateSysDataPanicRecovery(t *testing.T) { | ||
| log := logger.NewDummy() |
Comment on lines
+24
to
+25
| res2 := templateSysData(log, "test {{ .Values.NonExistent }}") | ||
| assert.Equal(t, "test {{ .Values.NonExistent }}", res2) |
AdamMagued
force-pushed
the
fix/issue-344-template-sysdata-panic
branch
from
November 14, 2026 14:54
07d6553 to
0185161
Compare
Author
lmk if you need any adjustments |
Signed-off-by: Adam Magued <adamismailmageud@gmail.com>
AdamMagued
force-pushed
the
fix/issue-344-template-sysdata-panic
branch
from
November 20, 2026 02:56
0185161 to
8945c1c
Compare
Author
|
I rebased the branch onto latest
lmk if you need any adjustments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #344
Problem
In
pkg/plugins/common.go,templateSysDatacallsjson.Marshal(&system). In certain environment states where sysinfo fields contain unexpected slice lengths or concurrent mutations,json.Marshalpanics withreflect: slice index out of range, causing early initramfs failure during system boot.Solution
defer recover()intemplateSysDatato catch unexpected reflection/marshalling panics, log a warning, and safely return the un-interpolated template string.Verified via container sandbox test suite.