fix: guard against nil config document slices - #14357
Open
smira wants to merge 1 commit into
Open
Conversation
This imports the gen library helper siderolabs/gen#34, and uses that to decode any machine config document, guarding against various `[]*T` places being nil. Remove now unneded validation (which was incomplete anyways). This protection applies to all code paths, including config patches. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
There was a problem hiding this comment.
🟡 Changes recommended
In-memory configs can still contain nil entries and cause validation panics; equivalent guards must be retained.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR centralizes rejection of null elements in config collections during decoding, including patches, upgrades gen, and removes redundant validation.
Changes:
- Upgrade
github.com/siderolabs/gen. - Add null-element decoder checks and tests.
- Remove overlapping validation checks.
File summaries
| File | Summary |
|---|---|
pkg/machinery/go.sum |
Updates dependency checksums. |
pkg/machinery/go.mod |
Upgrades the gen dependency. |
pkg/machinery/config/types/v1alpha1/v1alpha1_validation.go |
Removes nil-entry validation. |
pkg/machinery/config/configloader/internal/decoder/decoder.go |
Rejects null collection elements during decoding. |
pkg/machinery/config/configloader/internal/decoder/decoder_test.go |
Adds null-element decoder coverage. |
go.sum |
Updates dependency checksums. |
go.mod |
Updates the root gen dependency. |
Review details
- Files reviewed: 5/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
frezbo
approved these changes
Sep 11, 2026
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.
This imports the gen library helper
siderolabs/gen#34, and uses that to decode any machine config document, guarding against various
[]*Tplaces being nil.Remove now unneded validation (which was incomplete anyways).
This protection applies to all code paths, including config patches.