cayleygraph/cayley · error

cannot find node hash in query output (columns: %v, cind: %v

Error message

cannot find node hash in query output (columns: %v, cind: %v)

What it means

In scanValue, when only a single node value is expected (no per-direction column indexes), the code looks up quad.Any in it.cind to find which result column holds the node hash. If quad.Any is absent from cind, the node hash cannot be located in the query output and the error is recorded in it.err.

Source

Thrown at graph/sql/iterator.go:208

			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.err
}

func (it *iteratorBase) String() string {
	return it.query.SQL(NewBuilder(it.qs.flavor.QueryDialect))
}

func (qs *QuadStore) newIteratorNext(s Select) *iteratorNext {
	return &iteratorNext{
		iteratorBase: newIteratorBase(qs, s),
	}

View on GitHub (pinned to 81dcd7d73e)

Solutions

  1. Check the printed columns and cind map; ensure the Select includes the column mapped to quad.Any.
  2. Construct the iterator/Select with the library's own query-building helpers.
  3. Verify the iterator type matches the query shape (node vs quad selection).
Defensive patterns

Strategy: validation

Try / catch

for it.NextPath(ctx) { }
if err := it.Err(); err != nil {
    if strings.Contains(err.Error(), "cannot find node hash") {
        // Select is missing the node (quad.Any) column; rebuild the query
    }
}

Prevention

When it happens

Trigger: Next/NextPath/Contains on a SQL iterator whose Select output columns don't include the generic node column; it.cind has no quad.Any entry.

Common situations: Hand-written or altered Select statements missing the node hash column; column naming mismatches after schema changes; iterator built for quad output but fed node-only results (or vice versa).

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


AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06). Data as JSON: /api/errors/b9176900b44b7c4a. Report an issue: GitHub.