Skip to content

Commit f00a15a

Browse files
Accept inline YAML merge mappings in bundles (#7269)
**Bundles using an inline YAML merge mapping now pass validation.** The [merged acceptance fixture](https://github.com/databricks/cli/blob/a7e611477d067181ea538d3d8e1bd44ec1d9dfb5/acceptance/bundle/validate/yaml_anchors/inline_merge_mapping/test.toml) records `<<: {x: overridden}` as valid input that `bundle validate` previously rejected with `map merge requires map or sequence of maps as the value`. [PR #7085](#7085) introduced this fixture to pin that behavior. The YAML loader now accepts a mapping node as one merge source. The updated acceptance case checks `bundle validate -t dev` without `--strict` and the resolved JSON value of `variables.x`; a focused unit test checks that an explicit key takes precedence while another merged key remains. ## Local verification The five-file diff was checked on `codex/dabs-yaml-inline-merge-20261030` at its [recorded upstream base](a7e6114): - `TestYAMLInlineMapMerge` passed. - The focused inline-merge acceptance case passed without `--strict` with `DMS=` and `DMS=true`. Both modes reported `Validation OK!` and JSON `default` and `value` of `overridden`. - `git diff --check` passed. These are local checks; this body makes no CI claim. ## Candidate assignee Denis Bilenko (`denik`) authored [PR #7085](#7085), which added the inline-merge fixture.
1 parent 3e13357 commit f00a15a

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11

2-
>>> [CLI] bundle validate
3-
Error: failed to load [TEST_TMP_DIR]/databricks.yml: yaml ([TEST_TMP_DIR]/databricks.yml:11:11): map merge requires map or sequence of maps as the value
4-
5-
6-
Found 1 error
7-
8-
Exit code: 1
2+
>>> [CLI] bundle validate -t dev
3+
Name: test-bundle
4+
Target: dev
5+
Workspace:
6+
User: [USERNAME]
7+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/dev
8+
9+
Validation OK!
10+
11+
>>> [CLI] bundle validate -t dev -o json
12+
{
13+
"default": "overridden",
14+
"value": "overridden"
15+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# An inline mapping as the value of '<<' in target variables.
2-
errcode trace $CLI bundle validate
2+
trace $CLI bundle validate -t dev
3+
trace $CLI bundle validate -t dev -o json | jq .variables.x

‎acceptance/bundle/validate/yaml_anchors/inline_merge_mapping/test.toml‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎libs/dyn/yamlloader/loader.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (d *loader) loadMapping(node *yaml.Node, loc diag.Location) (dyn.Value, err
169169
switch merge.Kind {
170170
case yaml.SequenceNode:
171171
mnodes = merge.Content
172-
case yaml.AliasNode:
172+
case yaml.MappingNode, yaml.AliasNode:
173173
mnodes = []*yaml.Node{merge}
174174
default:
175175
return dyn.NilValue, merr

‎libs/dyn/yamlloader/yaml_anchor_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,12 @@ func TestYAMLAnchor10(t *testing.T) {
138138
assert.Equal(t, 1, self.Get("use1").Get("value").AsAny())
139139
assert.Equal(t, 1, self.Get("use2").Get("value").AsAny())
140140
}
141+
142+
func TestYAMLInlineMapMerge(t *testing.T) {
143+
input := "target:\n <<: {x: inherited, y: merged}\n x: local\n"
144+
value, err := yamlloader.LoadYAML("inline.yml", bytes.NewBufferString(input))
145+
require.NoError(t, err)
146+
147+
assert.Equal(t, "local", value.Get("target").Get("x").AsAny())
148+
assert.Equal(t, "merged", value.Get("target").Get("y").AsAny())
149+
}

0 commit comments

Comments
 (0)