From 08ecd39a1e47a59b581d4132cd1202feef61d003 Mon Sep 17 00:00:00 2001 From: Steven WdV Date: Wed, 16 Jul 2025 18:07:16 +0200 Subject: [PATCH] Add tests for invalid merge key handling for traverse --- pkg/yqlib/operator_traverse_path_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/yqlib/operator_traverse_path_test.go b/pkg/yqlib/operator_traverse_path_test.go index 58ae6263..65ec97f9 100644 --- a/pkg/yqlib/operator_traverse_path_test.go +++ b/pkg/yqlib/operator_traverse_path_test.go @@ -612,6 +612,25 @@ var traversePathOperatorScenarios = []expressionScenario{ "D0, P[a], (!!int)::2\n", }, }, + { + skipDoc: true, + description: "Traversing map with invalid merge anchor should not fail", + subdescription: "Otherwise code cannot do anything with it", + document: `{a: 42, <<: 37}`, + expression: `.a`, + expected: []string{ + "D0, P[a], (!!int)::42\n", + }, + }, + { + skipDoc: true, + description: "Directly accessing invalid merge anchor should not fail", + document: `{<<: 37}`, + expression: `.<<`, + expected: []string{ + "D0, P[<<], (!!int)::37\n", + }, + }, } func TestTraversePathOperatorScenarios(t *testing.T) {