{"record":{"id":"b9176900b44b7c4a","repo":"cayleygraph/cayley","slug":"cannot-find-node-hash-in-query-output-columns-v","errorCode":null,"errorMessage":"cannot find node hash in query output (columns: %v, cind: %v)","messagePattern":"cannot find node hash in query output \\(columns: (.+?), cind: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/sql/iterator.go","lineNumber":208,"sourceCode":"\t\t\tit.tags[name] = nodes[i].ValueHash\n\t\t}\n\t}\n\tif len(it.cind) > 1 {\n\t\tvar q QuadHashes\n\t\tfor _, d := range quad.Directions {\n\t\t\ti, ok := it.cind[d]\n\t\t\tif !ok {\n\t\t\t\tit.err = fmt.Errorf(\"cannot find quad %v in query output (columns: %v)\", d, it.cols)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tq.Set(d, nodes[i].ValueHash)\n\t\t}\n\t\tit.res = q\n\t\treturn true\n\t}\n\ti, ok := it.cind[quad.Any]\n\tif !ok {\n\t\tit.err = fmt.Errorf(\"cannot find node hash in query output (columns: %v, cind: %v)\", it.cols, it.cind)\n\t\treturn false\n\t}\n\tit.res = nodes[i]\n\treturn true\n}\n\nfunc (it *iteratorBase) Err() error {\n\treturn it.err\n}\n\nfunc (it *iteratorBase) String() string {\n\treturn it.query.SQL(NewBuilder(it.qs.flavor.QueryDialect))\n}\n\nfunc (qs *QuadStore) newIteratorNext(s Select) *iteratorNext {\n\treturn &iteratorNext{\n\t\titeratorBase: newIteratorBase(qs, s),\n\t}","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/sql/iterator.go#L190-L226","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Check the printed columns and cind map; ensure the Select includes the column mapped to quad.Any.","Construct the iterator/Select with the library's own query-building helpers.","Verify the iterator type matches the query shape (node vs quad selection)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"for it.NextPath(ctx) { }\nif err := it.Err(); err != nil {\n    if strings.Contains(err.Error(), \"cannot find node hash\") {\n        // Select is missing the node (quad.Any) column; rebuild the query\n    }\n}","preventionTips":["Include the node-hash column mapped to quad.Any in every node-selection query.","Match iterator type to query shape (node vs quad).","Use library helpers to construct Selects."],"tags":["sql","iterator","column-mapping"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}