Skip to content

Conversation

@james00012
Copy link
Contributor

@james00012 james00012 commented Oct 1, 2025

Summary

Fixes a segfault that occurs when helm.UnmarshalK8SYaml processes empty YAML documents (e.g., --- separators without content).

Changes

  1. Single object unmarshaling: Added nil check after decoding to return early when encountering empty documents
  2. Slice unmarshaling: Added nil check to skip empty documents in the loop
  3. Test coverage: Added EmptyDocument test case covering:
    • Single empty document separator (---)
    • Multiple empty separators (---\n---\n---)
    • Empty documents with slice destination

Root Cause

The YAML decoder successfully decodes empty documents but returns nil for rawYaml. The code then attempted to call json.Marshal(rawYaml) on nil, causing a segfault.

Test Plan

  • Added unit tests for empty document scenarios
  • Verified existing tests still pass
  • Confirmed no segfault with empty YAML documents

@james00012 james00012 force-pushed the fix/helm-unmarshal-segfault branch from ea73c7e to 183b248 Compare October 1, 2025 04:57
Copy link

@jeromepochat jeromepochat left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Thanks @james00012 !

@james00012 james00012 merged commit b4a5e8d into main Oct 4, 2025
2 of 3 checks passed
@james00012 james00012 deleted the fix/helm-unmarshal-segfault branch October 4, 2025 17:08
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.

4 participants