{"record":{"id":"2caa0108aa8694ff","repo":"mikefarah/yq","slug":"v-has-no-keys","errorCode":null,"errorMessage":"%v has no keys","messagePattern":"(.+?) has no keys","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_entries.go","lineNumber":56,"sourceCode":"\t\tsequence.AddChild(entrySeqFor(key, value))\n\t}\n\treturn sequence\n}\n\nfunc toEntriesOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {\n\tvar results = list.New()\n\tfor el := context.MatchingNodes.Front(); el != nil; el = el.Next() {\n\t\tcandidate := el.Value.(*CandidateNode)\n\n\t\tswitch candidate.Kind {\n\t\tcase MappingNode:\n\t\t\tresults.PushBack(toEntriesFromMap(candidate))\n\n\t\tcase SequenceNode:\n\t\t\tresults.PushBack(toEntriesfromSeq(candidate))\n\t\tdefault:\n\t\t\tif candidate.Tag != \"!!null\" {\n\t\t\t\treturn Context{}, fmt.Errorf(\"%v has no keys\", candidate.Tag)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn context.ChildContext(results), nil\n}\n\nfunc parseEntry(candidateNode *CandidateNode, position int) (*CandidateNode, *CandidateNode, error) {\n\tprefs := traversePreferences{DontAutoCreate: true}\n\n\tkeyResults, err := traverseMap(Context{}, candidateNode, createStringScalarNode(\"key\"), prefs, false)\n\n\tif err != nil {\n\t\treturn nil, nil, err\n\t} else if keyResults.Len() != 1 {\n\t\treturn nil, nil, fmt.Errorf(\"expected to find one 'key' entry but found %v in position %v\", keyResults.Len(), position)\n\t}\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_entries.go#L38-L74","documentation":"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.","triggerScenarios":"Thrown at pkg/yqlib/operator_entries.go:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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\")"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8b5af0694bb82b41d4ae180fac9972029066f90a","analyzedAt":"2026-09-05T10:57:22.766Z","contentChangedAt":"2026-09-05T10:57:22.766Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}