mikefarah/yq · error
DELPATHS: expected entry [%v] to be a sequence, but its a %v
Error message
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"]]
What it means
Each element inside the array passed to `delpaths` must itself be a sequence (array of path segments). This error reports the index of the offending entry and its actual tag, and reminds you that delpaths takes an array of path arrays. It exists because a non-sequence entry cannot be converted into a path array.
Source
Thrown at pkg/yqlib/operator_path.go:123
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}
deleteChildOpNode := &ExpressionNode{
Operation: deleteChildOp,
RHS: childTraversalExp,
}
updatedContext, err = d.GetMatchingNodes(updatedContext, deleteChildOpNode)
if err != nil {View on GitHub (pinned to 8b5af0694b)
Solutions
- Ensure every entry is an array: change `delpaths(["a"])` to `delpaths([["a"]])`.
- Check the reported index in the message — that entry is the malformed one.
- If generating paths programmatically, wrap each path in `[ ... ]` so entries are sequences.
- Validate with `map(tag == "!!seq") | all` before passing to delpaths.
Example fix
// before yq 'delpaths(["a", "b"])' file.yml // after yq 'delpaths([["a"], ["b"]])' file.yml
Defensive patterns
Strategy: validation
Validate before calling
yq -e 'map(tag == "!!seq") | all' <<< "$paths" || echo "every delpaths entry must be an array"
Type guard
isSeqOfSeqs() { [ "$(yq 'map(tag == "!!seq") | all' <<< "$1")" = "true" ]; } Try / catch
out=$(yq 'delpaths($p)' file.yml 2>&1) || { echo "$out"; echo "check entry at reported index — must be a path array"; } Prevention
- Remember jq's delpaths(["a"]) shorthand is invalid in yq — wrap each path in its own array.
- When building paths programmatically, wrap each path: map([.]).
- Test path arrays with map(tag == "!!seq") | all before use.
- Read the entry index from the error message to pinpoint the bad element.
When it happens
Trigger: `delpaths(["a"])` (entry 0 is a scalar string, not an array), `delpaths([["a"], "b"])`, or entries produced by an expression returning maps/scalars instead of path arrays.
Common situations: Mixing jq `delpaths(["a"])` shorthand with yq's stricter `[ path, ... ]` shape; building path lists dynamically where some entries are strings rather than arrays; forgetting the outer level of nesting.
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 a sequence of sequences, but found %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/c0ff341db7939098.
Report an issue: GitHub.