{"record":{"id":"89e7e6e98a91b9ba","repo":"mikefarah/yq","slug":"expected-to-find-one-value-entry-but-found-v-in","errorCode":null,"errorMessage":"expected to find one 'value' entry but found %v in position %v","messagePattern":"expected to find one 'value' entry but found (.+?) in position (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_entries.go","lineNumber":80,"sourceCode":"}\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\n\tvalueResults, err := traverseMap(Context{}, candidateNode, createStringScalarNode(\"value\"), prefs, false)\n\n\tif err != nil {\n\t\treturn nil, nil, err\n\t} else if valueResults.Len() != 1 {\n\t\treturn nil, nil, fmt.Errorf(\"expected to find one 'value' entry but found %v in position %v\", valueResults.Len(), position)\n\t}\n\n\treturn keyResults.Front().Value.(*CandidateNode), valueResults.Front().Value.(*CandidateNode), nil\n\n}\n\nfunc fromEntries(candidateNode *CandidateNode) (*CandidateNode, error) {\n\tvar node = candidateNode.CopyWithoutContent()\n\n\tvar contents = candidateNode.Content\n\n\tfor index := 0; index < len(contents); index = index + 1 {\n\t\tkey, value, err := parseEntry(contents[index], index)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tnode.AddKeyValueChild(key, value)","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_entries.go#L62-L98","documentation":"yq's `to_entries`-related entry parsing (parseEntry) converts a {key, value} object into a key/value pair. After traversing the candidate's `value` key it expects exactly one matching node. If the object has zero or multiple `value` entries (e.g. a malformed or multi-value entry object), the operator cannot form a single entry and fails. This is a validation error thrown while building maps from entries, typically via `with_entries`/`from_entries` input that isn't a proper {key, value} map.","triggerScenarios":"Running `with_entries` or `from_entries` over an array whose elements are maps that lack a `value` key, or whose `value` key traversal returns more than one result (e.g. via unusual node content or aliases).","commonSituations":"Users feed objects missing `value` (only `{key: x}`) into from_entries; documents built by other tools contain entry-like objects with extra/multiple value fields; keys spelled differently (`name`/`val`) are passed in expecting from_entries to accept them.","solutions":["Ensure each array element is an object with exactly one `key` and one `value` entry before using from_entries/with_entries","Transform mismatched fields first, e.g. `.[] |= {key: .name, value: .val}` before from_entries","Filter out malformed elements with map(select(has(\"value\")))","If using a different key name, rename it to `value` upstream"],"exampleFix":"// before\n[{key: \"a\"}] | from_entries\n// error: expected to find one 'value' entry but found 0 in position 0\n\n// after\n[{key: \"a\", value: 1}] | from_entries","handlingStrategy":"validation","validationCode":"# ensure every element has exactly one key and one value\nyq '[.[] | select(has(\"key\") and has(\"value\"))] | all(. == true)' entries.yaml","typeGuard":"def is_entry(o):\n    return isinstance(o, dict) and \"key\" in o and \"value\" in o","tryCatchPattern":"out=$(yq 'from_entries' in.yaml 2>&1) || {\n  echo \"malformed entry objects: $out\" >&2\n  exit 1\n}","preventionTips":["Always generate entry objects as {key: ..., value: ...}","Run to_entries before editing so structure stays canonical","Validate with has(\"key\") and has(\"value\") before from_entries"],"tags":["yq","entries","validation"],"backgroundTag":"invalid-entry-object","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"}