diff --git a/pkg/yqlib/operator_anchors_aliases.go b/pkg/yqlib/operator_anchors_aliases.go index a33006e7..b9326934 100644 --- a/pkg/yqlib/operator_anchors_aliases.go +++ b/pkg/yqlib/operator_anchors_aliases.go @@ -245,6 +245,7 @@ func applyMergeAnchor(node *CandidateNode, merge *CandidateNode, mergeIndex int, return fmt.Errorf( "can only use merge anchors with maps (!!map) or sequences (!!seq) of maps, but got sequence containing %v", childValue.Tag) + return nil } err := applyMergeAnchorMap(node, childValue, mergeIndex, context.ChildContext(newContent)) if err != nil { diff --git a/pkg/yqlib/operator_traverse_path.go b/pkg/yqlib/operator_traverse_path.go index f3afaf41..88c8f31d 100644 --- a/pkg/yqlib/operator_traverse_path.go +++ b/pkg/yqlib/operator_traverse_path.go @@ -305,9 +305,10 @@ func traverseMergeAnchor(newMatches *orderedmap.OrderedMap, value *CandidateNode childValue = childValue.Alias } if childValue.Kind != MappingNode { - return fmt.Errorf( + log.Debugf( "can only use merge anchors with maps (!!map) or sequences (!!seq) of maps, but got sequence containing %v", childValue.Tag) + return nil } err := doTraverseMap(newMatches, childValue, wantedKey, prefs, splat) if err != nil { @@ -316,7 +317,8 @@ func traverseMergeAnchor(newMatches *orderedmap.OrderedMap, value *CandidateNode } return nil default: - return fmt.Errorf("can only use merge anchors with maps (!!map) or sequences (!!seq) of maps, but got %v", value.Tag) + log.Debugf("can only use merge anchors with maps (!!map) or sequences (!!seq) of maps, but got %v", merge.Tag) + return nil } } diff --git a/pkg/yqlib/operator_traverse_path_test.go b/pkg/yqlib/operator_traverse_path_test.go index 114c728e..bf1cad19 100644 --- a/pkg/yqlib/operator_traverse_path_test.go +++ b/pkg/yqlib/operator_traverse_path_test.go @@ -573,20 +573,6 @@ var traversePathOperatorScenarios = []expressionScenario{ "D0, P[a 2], (!!str)::c\n", }, }, - { - skipDoc: true, - document: badAliasSample, - expression: ".steps[]", - expectedError: "can only use merge anchors with maps (!!map) or sequences (!!seq) of maps, but got sequence containing !!str", - skipForGoccy: true, // throws an error on parsing, that's fine - }, - { - skipDoc: true, - document: `{<<: 42}`, - expression: ".[]", - expectedError: "can only use merge anchors with maps (!!map) or sequences (!!seq) of maps, but got !!int", - skipForGoccy: true, - }, } func TestTraversePathOperatorScenarios(t *testing.T) {