mikefarah/yq · error
%v has no keys
Error message
%v has no keys
What it means
to_entries requires each matched node to be a mapping or sequence (both yield key/value entries); nulls are silently skipped. Any other kind — the tag is printed, typically !!str or !!bool — reaches the default branch and errors, because a scalar fundamentally has no keys to enumerate.
Source
Thrown at pkg/yqlib/operator_entries.go:56
sequence.AddChild(entrySeqFor(key, value))
}
return sequence
}
func toEntriesOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
switch candidate.Kind {
case MappingNode:
results.PushBack(toEntriesFromMap(candidate))
case SequenceNode:
results.PushBack(toEntriesfromSeq(candidate))
default:
if candidate.Tag != "!!null" {
return Context{}, fmt.Errorf("%v has no keys", candidate.Tag)
}
}
}
return context.ChildContext(results), nil
}
func parseEntry(candidateNode *CandidateNode, position int) (*CandidateNode, *CandidateNode, error) {
prefs := traversePreferences{DontAutoCreate: true}
keyResults, err := traverseMap(Context{}, candidateNode, createStringScalarNode("key"), prefs, false)
if err != nil {
return nil, nil, err
} else if keyResults.Len() != 1 {
return nil, nil, fmt.Errorf("expected to find one 'key' entry but found %v in position %v", keyResults.Len(), position)
}
View on GitHub (pinned to 8b5af0694b)
Solutions
- Apply to_entries only to maps/arrays: . | to_entries
- Wrap scalars if needed: {value: .} | to_entries
- Filter non-map nodes first with select(type == "!!map")
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at pkg/yqlib/operator_entries.go:56 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/2caa0108aa8694ff.
Report an issue: GitHub.