cayleygraph/cayley · error
cannot find quad %v in query output (columns: %v)
Error message
cannot find quad %v in query output (columns: %v)
What it means
In scanValue, when the iterator expects a full quad (multiple column indexes in it.cind), each quad direction (subject/predicate/object/label) must map to a query output column. This error means a required direction column is missing from the SELECT result, so the quad cannot be reconstructed. It is stored in it.err and aborts the scan.
Source
Thrown at graph/sql/iterator.go:198
for i := range pointers {
pointers[i] = &nodes[i]
}
if err := r.Scan(pointers...); err != nil {
it.err = err
return false
}
it.tags = make(map[string]graph.Ref)
for i, name := range it.cols {
if !strings.Contains(name, tagPref) {
it.tags[name] = nodes[i].ValueHash
}
}
if len(it.cind) > 1 {
var q QuadHashes
for _, d := range quad.Directions {
i, ok := it.cind[d]
if !ok {
it.err = fmt.Errorf("cannot find quad %v in query output (columns: %v)", d, it.cols)
return false
}
q.Set(d, nodes[i].ValueHash)
}
it.res = q
return true
}
i, ok := it.cind[quad.Any]
if !ok {
it.err = fmt.Errorf("cannot find node hash in query output (columns: %v, cind: %v)", it.cols, it.cind)
return false
}
it.res = nodes[i]
return true
}
func (it *iteratorBase) Err() error {
return it.errView on GitHub (pinned to 81dcd7d73e)
Solutions
- Inspect the printed columns list and ensure your Select requests a column for every quad direction used.
- Build Selects via the library's helper methods rather than hand-crafting column lists.
- Check for version mismatches between the store schema and the library expecting per-direction columns.
Defensive patterns
Strategy: validation
Try / catch
for it.Next(ctx) { }
if it.Err() != nil {
if strings.Contains(it.Err().Error(), "cannot find quad") {
// rebuild the Select with all quad direction columns
}
} Prevention
- Build Selects with the library's query-building helpers, never hand-crafted column lists.
- Ensure every quad direction used by the iterator has a corresponding output column.
- Keep the DB schema in sync with the library version.
When it happens
Trigger: Running a Next/NextPath/Contains on a SQL iterator built with a Select that requests quad directions, where the query result columns (it.cols) lack a column for one of the directions.
Common situations: Custom or hand-built Select statements whose column set doesn't match the directions the iterator expects; schema/column aliasing changes after an upgrade; queries optimized away a direction.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- cannot find node hash in query output (columns: %v, cind: %v
- must execute a IteratorStep or PathStep
- no quad store in Iterate
- unexpected node type: %T
- expected KV quadstore, got: %T
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/a979414e702b8c90.
Report an issue: GitHub.