fix: std.parseYaml supports YAML merge keys (<<)#1027
Open
He-Pin wants to merge 4 commits into
Open
Conversation
The MappingNode handler in Platform.scala now checks for Tag.MERGE on key nodes. When a merge key is encountered, the referenced mapping (or sequence of mappings) is resolved and its entries are inlined into the current mapping with lower priority than explicit keys, matching the YAML merge key spec and go-jsonnet/jrsonnet behavior.
Motivation: The YAML merge key (<<) fix is JVM-only (SnakeYAML specific). The JS/WASM and Native platforms use scala-yaml which handles merge keys differently. Skip the test on non-JVM platforms to avoid CI failures. Modification: - src-js/FileTests.scala: Add parseyaml_merge_keys.jsonnet to skippedTests - src-jvm-native/FileTests.scala: Add to Scala Native skip list
Motivation: The skippedTests/testDataSkippedTests filter was only applied to test_suite, not to new_test_suite. This caused JVM-only tests (parseyaml_merge_keys.jsonnet) to run and fail on JS/WASM/Native. Modification: - src-js/FileTests.scala: Add .filter(f => !skippedTests.contains(f)) to new_test_suite section - src-jvm-native/FileTests.scala: Add .filter(f => !testDataSkippedTests.contains(f.last)) to new_test_suite section
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.
fix: std.parseYaml supports YAML merge keys (<<)
Motivation
std.parseYamldid not support YAML merge key expansion. The<<key was kept as a literal string key instead of merging the referenced mapping's fields into the parent. Both go-jsonnet and jrsonnet correctly implement this YAML spec feature.Example:
Expected:
{"defaults":{"x":1,"y":2},"item":{"x":1,"y":2,"z":3}}Before:
{"defaults":{"x":1,"y":2},"item":{"<<":{"x":1,"y":2},"z":3}}Modification
Platform.scala(JVM): Modified theMappingNodehandler inyamlNodeToJsonto detectTag.MERGEon key nodes and inline the referenced mapping's entries with lower priority than explicit keys (per YAML spec). Supports both single alias (<<: *def) and sequence of aliases (<<: [*a, *b]).parseyaml_merge_keys.jsonnetResult
Merge keys are now correctly expanded, matching go-jsonnet and jrsonnet output.
<<as literal key ❌