mikefarah/yq · error
DELPATHS: expected a sequence of sequences, but found %v
Error message
DELPATHS: expected a sequence of sequences, but found %v
What it means
The `delpaths` operator expects its argument to be a sequence (array) whose entries are themselves sequences of path segments. This error is thrown when the top-level argument is not an array at all (e.g. a scalar or a map). yq throws it to stop you from passing a malformed path spec that cannot be interpreted as a list of paths.
Source
Thrown at pkg/yqlib/operator_path.go:115
}
return context, nil
}
func delPathsOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("delPaths")
// single RHS expression that returns an array of paths (array of arrays)
pathArraysContext, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)
if err != nil {
return Context{}, err
}
if pathArraysContext.MatchingNodes.Len() != 1 {
return Context{}, fmt.Errorf("DELPATHS: expected single value but found %v", pathArraysContext.MatchingNodes.Len())
}
pathArraysNode := pathArraysContext.MatchingNodes.Front().Value.(*CandidateNode)
if pathArraysNode.Tag != "!!seq" {
return Context{}, fmt.Errorf("DELPATHS: expected a sequence of sequences, but found %v", pathArraysNode.Tag)
}
updatedContext := context
for i, child := range pathArraysNode.Content {
if child.Tag != "!!seq" {
return 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)
}
childPath, err := getPathArrayFromNode("DELPATHS", child)
if err != nil {
return Context{}, err
}
childTraversalExp := createTraversalTree(childPath, traversePreferences{}, false)
deleteChildOp := &Operation{OperationType: deleteChildOpType}
View on GitHub (pinned to 8b5af0694b)
Solutions
- Wrap the argument as an array of path arrays: use `delpaths(["a"])` instead of `delpaths("a")`.
- Verify the expression feeding delpaths evaluates to a sequence: `select(tag == "!!seq")` or inspect with `tag`.
- If deleting a single path, either use `del(.a.b)` or pass `delpaths([["a","b"]])`.
- If the argument comes from data, ensure it is an array of arrays, e.g. `[paths]` style construction.
Example fix
// before
yq 'delpaths("a.b")' file.yml
// after
yq 'delpaths([["a", "b"]])' file.yml Defensive patterns
Strategy: validation
Validate before calling
paths=$(yq -o=json '[paths]' file.yml); yq --argjson p "$paths" 'delpaths($p)' file.yml # ensure argument is an array of arrays
Type guard
isPathArrays() { [ "$(yq 'tag == "!!seq" and (map(tag == "!!seq") | all)' <<< "$1")" = "true" ]; } Prevention
- Always pass delpaths an array of path arrays: [["a","b"]].
- Use del(.path) for single-path deletions to avoid nesting confusion.
- Check the tag of the argument expression before calling delpaths.
- Never feed scalar/map data directly into delpaths.
When it happens
Trigger: Calling `delpaths(...)` where the argument expression evaluates to a single non-sequence node — e.g. `yq 'delpaths("a")'`, `delpaths({})`, or `delpaths(.foo)` where .foo is a scalar/map.
Common situations: Copy-pasting jq-style single-path usage like `delpaths(["a","b"])` without the extra nesting level; accidentally selecting a scalar/map instead of an array of paths; forgetting that delpaths takes `[["a"]]` not `["a"]`.
Related errors
- %v: expected path array, but got %v instead
- %v: expected either a !!str or !!int in the path, found %v i
- DELPATHS: expected entry [%v] to be a sequence, but its a %v
- %v (%v) cannot be subtracted from %v
- %v cannot check contained in %v
AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05).
Data as JSON: /api/errors/550a7dd91daf80cf.
Report an issue: GitHub.