{"record":{"id":"1f00c6a90ab28357","repo":"cayleygraph/cayley","slug":"unexpected-node-type-t","errorCode":null,"errorMessage":"unexpected node type: %T","messagePattern":"unexpected node type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/kv/iterators.go","lineNumber":82,"sourceCode":"\t\t}\n\t}\n\tst, err := qs.Stats(ctx, false)\n\tif err != nil {\n\t\treturn refs.Size{}, err\n\t}\n\treturn refs.Size{\n\t\tValue: 1 + st.Quads.Value/2,\n\t\tExact: false,\n\t}, nil\n}\n\nfunc (qs *QuadStore) QuadIterator(dir quad.Direction, v graph.Ref) iterator.Shape {\n\tif v == nil {\n\t\treturn iterator.NewNull()\n\t}\n\tvi, ok := v.(Int64Value)\n\tif !ok {\n\t\treturn iterator.NewError(fmt.Errorf(\"unexpected node type: %T\", v))\n\t}\n\t// Find the best index for this direction.\n\tif ind := qs.bestIndexes([]quad.Direction{dir}); len(ind) == 1 {\n\t\t// this will scan the prefix automatically\n\t\treturn qs.newQuadIterator(ind[0], []uint64{uint64(vi)})\n\t}\n\t// Fallback: iterate all quads and check the corresponding direction.\n\treturn qs.newAllIterator(false, &constraint{\n\t\tdir: dir,\n\t\tval: vi,\n\t})\n}\n\nfunc (qs *QuadStore) OptimizeShape(ctx context.Context, s shape.Shape) (shape.Shape, bool) {\n\tswitch s := s.(type) {\n\tcase shape.QuadsAction:\n\t\treturn qs.optimizeQuadsAction(s)\n\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/kv/iterators.go#L64-L100","documentation":"QuadIterator was given a node reference (graph.Ref) that is not an Int64Value. The KV quadstore identifies nodes internally as uint64 IDs, so any other Ref implementation cannot be used to build a direction-scoped iterator, and an error iterator is returned instead.","triggerScenarios":"Calling qs.QuadIterator(dir, v) where v came from a different QuadStore implementation (e.g. a string-based store) or is any concrete type other than Int64Value.","commonSituations":"Mixing graph.Refs across backend implementations, using Node values from JSON/HTTP API responses without resolving them to KV int64 IDs, or after migrating stores between backends.","solutions":["Only pass Refs obtained from this same KV QuadStore (NameOf/Value lookups), not from other backends.","Convert the node to the store's Int64Value via qs.ValueOf/lookup before building the iterator.","Check that the graph.Ref you hold is not a wrapped or pointer type that fails the Int64Value assertion."],"exampleFix":"// before\nit := qs.QuadIterator(quad.Subject, someStringRef)\n// after\nval := qs.ValueOf(nodeName)\nit := qs.QuadIterator(quad.Subject, val) // returns Int64Value for KV store","handlingStrategy":"type-guard","validationCode":"if _, ok := ref.(kv.Int64Value); !ok { /* obtain a proper ref via qs.ValueOf before iterating */ }","typeGuard":"func isInt64Ref(r graph.Ref) bool { _, ok := r.(kv.Int64Value); return ok }","tryCatchPattern":"it := qs.QuadIterator(dir, ref)\nif iterator.IsError(it) { ref = qs.ValueOf(name); it = qs.QuadIterator(dir, ref) }","preventionTips":["Never mix graph.Refs between different QuadStore implementations.","Always obtain node refs from the same store instance you iterate on.","After migrating backends, re-resolve all node references before iterating."],"tags":["iterator","type-mismatch","kv-store"],"backgroundTag":"type-mismatch","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"}