mikefarah/yq · error
any only supports arrays, was %v
Error message
any only supports arrays, was %v
What it means
The any operator, like all, requires each matched node to be a SequenceNode so it can test its predicate over the elements. This guard fires on the first matched node whose tag is not !!seq (the actual tag replaces %v), e.g. running any directly against a map value or a scalar.
Source
Thrown at pkg/yqlib/operator_booleans.go:109
return Context{}, fmt.Errorf("all only supports arrays, was %v", candidate.Tag)
}
booleanResult, err := findBoolean(false, d, context, expressionNode.RHS, candidate)
if err != nil {
return Context{}, err
}
result := createBooleanCandidate(candidate, !booleanResult)
results.PushBack(result)
}
return context.ChildContext(results), nil
}
func anyOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
if candidate.Kind != SequenceNode {
return Context{}, fmt.Errorf("any only supports arrays, was %v", candidate.Tag)
}
booleanResult, err := findBoolean(true, d, context, expressionNode.RHS, candidate)
if err != nil {
return Context{}, err
}
result := createBooleanCandidate(candidate, booleanResult)
results.PushBack(result)
}
return context.ChildContext(results), nil
}
func orOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
prefs := crossFunctionPreferences{
CalcWhenEmpty: true,
Calculation: returnRhsTruthy,
LhsResultValue: returnLHSWhen(true),
}
return crossFunctionWithPrefs(d, context.ReadOnlyClone(), expressionNode, prefs)View on GitHub (pinned to 8b5af0694b)
Solutions
- Apply any only to arrays: .tags | any(. == "x")
- Convert to an array first with [...] or [.[] | ... ]
- Verify upstream that the field exists and is a list, not a scalar/map
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at pkg/yqlib/operator_booleans.go:109 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05).
Data as JSON: /api/errors/ef32e7d520f8af86.
Report an issue: GitHub.