mikefarah/yq · error
%v not yet supported for comparison
Error message
%v not yet supported for comparison
What it means
compareScalars implements ordering only for int/float pairs, string pairs, timestamps, and null. If the lhs tag falls outside every supported branch (e.g. !!bool, custom tags that do not resolve, !!merge), it falls through to this error. The rhs may be fine; it is specifically the lhs tag that yq does not know how to order.
Source
Thrown at pkg/yqlib/operator_compare.go:131
if prefs.Greater {
return lhsNum > rhsNum, nil
}
return lhsNum < rhsNum, nil
} else if lhsTag == "!!str" && rhsTag == "!!str" {
if prefs.OrEqual && lhs.Value == rhs.Value {
return true, nil
}
if prefs.Greater {
return lhs.Value > rhs.Value, nil
}
return lhs.Value < rhs.Value, nil
} else if lhsTag == "!!null" && rhsTag == "!!null" && prefs.OrEqual {
return true, nil
} else if lhsTag == "!!null" || rhsTag == "!!null" {
return false, nil
}
return false, fmt.Errorf("%v not yet supported for comparison", lhs.Tag)
}
func superlativeByComparison(d *dataTreeNavigator, context Context, prefs compareTypePref) (Context, error) {
fn := compare(prefs)
var results = list.New()
for seq := context.MatchingNodes.Front(); seq != nil; seq = seq.Next() {
splatted, err := splat(context.SingleChildContext(seq.Value.(*CandidateNode)), traversePreferences{})
if err != nil {
return Context{}, err
}
result := splatted.MatchingNodes.Front()
if result != nil {
for el := result.Next(); el != nil; el = el.Next() {
cmp, err := fn(d, context, el.Value.(*CandidateNode), result.Value.(*CandidateNode))
if err != nil {
return Context{}, errView on GitHub (pinned to 8b5af0694b)
Solutions
- Convert booleans to numbers before comparing: `.enabled | tonumber`-style, or compare with ==/!= which works for bools.
- If sorting bools, map them to ints first: `sort_by(.enabled == true)` or use select-based filtering instead of ordering.
- Inspect the actual tags with `yq '... | tag'` to confirm both operands are str/int/float.
- Explicitly cast strings: if 'true' is really a string, ensure quoting so the tag is !!str and string comparison applies.
Example fix
# before yq 'sort_by(.enabled)' file.yaml # .enabled is !!bool -> error # after yq 'sort_by(.enabled == "true" or .enabled == true)' file.yaml # or compare with == instead of ordering
Defensive patterns
Strategy: type-guard
Validate before calling
# verify operand tags are orderable (str/int/float) before comparing: yq -e '.enabled | tag == "!!str" or tag == "!!int" or tag == "!!float"' file.yaml || echo "unorderable tag"
Type guard
// yq expression guard: restrict ordering comparisons to numeric/string tags // yq 'select(tag == "!!int" or tag == "!!float" or tag == "!!str") | . > .other' file.yaml
Prevention
- Do not use <,<=,>,>= on booleans; use ==/!= or map to numbers
- Check tags with `tag` when comparing values from external tools
- Convert booleans/enums to comparable scalars before sort_by/min/max
- Avoid custom-tagged nodes in ordering expressions unless they resolve to str/int/float
When it happens
Trigger: Comparing boolean values with <, <=, >, >=, e.g. `yq '.enabled > .verbose' file.yaml` where both are !!bool; comparing a custom-typed node whose guessTagFromCustomType does not reduce to str/int/float/null; sort_by/min/max over sequences of booleans or other untagged-unsupported scalars.
Common situations: Sorting or min/max over boolean flags in config files; comparing env-style 'true'/'false' strings that yq parsed as !!bool; data produced by tools that emit exotic tags (e.g. !!binary) fed into ordering expressions; users expecting bools to be orderable like in Python (False < True).
Related errors
- maps not yet supported for comparison
- arrays not yet supported for comparison
- %v (%v) cannot be subtracted from %v
- %v not yet supported for contains
- can only pivot elements of !!seq or !!map types, received %v
AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05).
Data as JSON: /api/errors/e47657b84b892fa6.
Report an issue: GitHub.