{"record":{"id":"88a4b5cc8d887c54","repo":"mikefarah/yq","slug":"delpaths-expected-single-value-but-found-v","errorCode":null,"errorMessage":"DELPATHS: expected single value but found %v","messagePattern":"DELPATHS: expected single value but found (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_path.go","lineNumber":110,"sourceCode":"\n\t\tif err != nil {\n\t\t\treturn Context{}, err\n\t\t}\n\n\t}\n\treturn context, nil\n}\n\nfunc delPathsOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {\n\tlog.Debugf(\"delPaths\")\n\t// single RHS expression that returns an array of paths (array of arrays)\n\n\tpathArraysContext, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)\n\tif err != nil {\n\t\treturn Context{}, err\n\t}\n\tif pathArraysContext.MatchingNodes.Len() != 1 {\n\t\treturn Context{}, fmt.Errorf(\"DELPATHS: expected single value but found %v\", pathArraysContext.MatchingNodes.Len())\n\t}\n\tpathArraysNode := pathArraysContext.MatchingNodes.Front().Value.(*CandidateNode)\n\n\tif pathArraysNode.Tag != \"!!seq\" {\n\t\treturn Context{}, fmt.Errorf(\"DELPATHS: expected a sequence of sequences, but found %v\", pathArraysNode.Tag)\n\t}\n\n\tupdatedContext := context\n\n\tfor i, child := range pathArraysNode.Content {\n\n\t\tif child.Tag != \"!!seq\" {\n\t\t\treturn Context{}, fmt.Errorf(\"DELPATHS: expected entry [%v] to be a sequence, but its a %v. Note that delpaths takes an array of path arrays, e.g. [[\\\"a\\\", \\\"b\\\"]]\", i, child.Tag)\n\t\t}\n\t\tchildPath, err := getPathArrayFromNode(\"DELPATHS\", child)\n\n\t\tif err != nil {\n\t\t\treturn Context{}, err","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_path.go#L92-L128","documentation":"DELPATHS takes exactly one argument: a single array of path arrays (e.g. [[\"a\",\"b\"], [\"c\"]]). This error is thrown when the RHS expression evaluates to a number of results other than 1 (0 if it matches nothing, >1 if it fans out), before the sequence-of-sequences check happens.","triggerScenarios":"'delpaths(.paths[])' (iterator -> many results), 'delpaths(.missing)' on documents where the expression yields null/nothing, or an expression with multiple outputs.","commonSituations":"Forgetting the array-of-arrays structure and passing an iterator, documents where the paths variable is absent, expressions ported from jq where delpaths also expects exactly one argument but failure modes differ.","solutions":["Ensure the argument yields a single array: 'delpaths([ [\"a\"], [\"b\"] ])'","Collapse multiple results into one: 'delpaths([.paths[]])' wraps elements into one array","Use 'first' or select to reduce the expression to a single match"],"exampleFix":"// before\nyq 'delpaths(.toDelete[])' f.yml   // multiple results\n// after\nyq 'delpaths([.toDelete[]])' f.yml","handlingStrategy":"validation","validationCode":"yq '<expr> | length' f.yml  # must print exactly 1\nyq '<expr> | tag' f.yml     # must print !!seq","typeGuard":"yq 'select((<expr> | length) == 1 and (<expr> | tag) == \"!!seq\")' f.yml","tryCatchPattern":"// shell\nout=$(yq 'delpaths(.p[])' f.yml 2>&1) || { echo \"delpaths arg invalid: $out\"; exit 1; }","preventionTips":["Always pass one array of path arrays: delpaths([[\"a\"],[\"b\"]])","Wrap iterators: [expr] to collapse multiple results into one","Verify the argument with '| length' and '| tag' first"],"tags":["yq","delpaths","cardinality","path-expression"],"backgroundTag":"unexpected-match-count","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"}