diff --git a/pkg/yqlib/path_tree.go b/pkg/yqlib/path_tree.go index a9d1ea06..4ea6f42f 100644 --- a/pkg/yqlib/path_tree.go +++ b/pkg/yqlib/path_tree.go @@ -71,7 +71,7 @@ func (p *pathTreeCreator) CreatePathTree(postFixPath []*Operation) (*PathTreeNod stack = append(stack, &newNode) } if len(stack) != 1 { - return nil, fmt.Errorf("expected stack to have 1 thing but its %v", stack) + return nil, fmt.Errorf("expected end of expression but found '%v', please check expression syntax", strings.TrimSpace(stack[1].Operation.StringValue)) } return stack[0], nil } diff --git a/pkg/yqlib/path_tree_test.go b/pkg/yqlib/path_tree_test.go index bd5d618e..6b2ab713 100644 --- a/pkg/yqlib/path_tree_test.go +++ b/pkg/yqlib/path_tree_test.go @@ -35,3 +35,8 @@ func TestPathTreeOneArgForOneArgOp(t *testing.T) { _, err := treeCreator.ParsePath("explode(.)") test.AssertResultComplex(t, nil, err) } + +func TestPathTreeExtraArgs(t *testing.T) { + _, err := treeCreator.ParsePath("sortKeys(.) explode(.)") + test.AssertResultComplex(t, "expected end of expression but found 'explode', please check expression syntax", err.Error()) +}