Skip to content

Fix #776#783

Open
Madoxen wants to merge 1 commit intogoccy:masterfrom
barney-ci:fix-776
Open

Fix #776#783
Madoxen wants to merge 1 commit intogoccy:masterfrom
barney-ci:fix-776

Conversation

@Madoxen
Copy link
Copy Markdown

@Madoxen Madoxen commented Aug 11, 2025

Unmarshal from yamls with sequence merge key has been working fine for generic maps (aka. map[string]any types), but has been broken for structs: see #776 for more details.

This commits fixes that, by properly handling marking a sequence as isMerge in keyToNodeMap. Previously it always assumed that the entry node will be always a map, despite having logic for properly handling these.

A test case was also added, one which exercises struct unmarshaling logic.

Fixes: #776

Unmarshal from yamls with sequence merge key has been working fine for
generic maps (aka. map[string]any types), but has been broken for
structs.

This commits fixes that, by properly handling marking a sequence as
`isMerge` in keyToNodeMap. Perviously it always assumed that the entry
node will be always a map, despite having logic for properly handling
these.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 11, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.97%. Comparing base (25e5d90) to head (149ccc0).
⚠️ Report is 13 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #783   +/-   ##
=======================================
  Coverage   77.97%   77.97%           
=======================================
  Files          22       22           
  Lines        8108     8110    +2     
=======================================
+ Hits         6322     6324    +2     
  Misses       1370     1370           
  Partials      416      416           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Madoxen
Copy link
Copy Markdown
Author

Madoxen commented Jan 27, 2026

@goccy any chance on merging this?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes issue #776 where unmarshaling YAML with sequence merge keys (<<: [*a, *b]) was failing for structs but working for generic maps. The root cause was that the code wasn't properly passing the merge context flag through the call chain, causing getMapNode to reject sequence nodes even when processing merge keys.

Changes:

  • Added an isMerge parameter to track when processing merge key values in the decode logic
  • Added test coverage for struct unmarshaling with sequence merge keys
  • Added test coverage to ensure map unmarshaling continues to work correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
decode.go Refactored keyToNodeMap to accept an isMerge parameter via a new internal _keyToNodeMap function, and properly passes isMerge=true when recursively processing merge key values
decode_test.go Added two test cases exercising struct and map unmarshaling with sequence merge keys (<<: [*a, *b])

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Error code 2 when parsing yaml with multiple merge keys like <<: [*a, *b]

3 participants