{"record":{"id":"f520ac7124e7fb36","repo":"cayleygraph/cayley","slug":"unknown-type-of-graph-ref-not-meant-for-this-quad","errorCode":null,"errorMessage":"unknown type of graph.Ref; not meant for this quadstore. apparently a %#v","messagePattern":"unknown type of graph\\.Ref; not meant for this quadstore\\. apparently a %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/kv/quadstore.go","lineNumber":323,"sourceCode":"\t\tinds  []int\n\t\tirefs []uint64\n\t)\n\tfor i, v := range vals {\n\t\tif v == nil {\n\t\t\tcontinue\n\t\t} else if pv, ok := v.(refs.PreFetchedValue); ok {\n\t\t\tout[i] = pv.NameOf()\n\t\t\tcontinue\n\t\t}\n\t\tswitch v := v.(type) {\n\t\tcase Int64Value:\n\t\t\tif v == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tinds = append(inds, i)\n\t\t\tirefs = append(irefs, uint64(v))\n\t\tdefault:\n\t\t\treturn out, fmt.Errorf(\"unknown type of graph.Ref; not meant for this quadstore. apparently a %#v\", v)\n\t\t}\n\t}\n\tif len(irefs) == 0 {\n\t\treturn out, nil\n\t}\n\tprim, err := qs.getPrimitives(ctx, irefs)\n\tif err != nil {\n\t\treturn out, err\n\t}\n\tvar last error\n\tfor i, p := range prim {\n\t\tif p == nil || !p.IsNode() {\n\t\t\tcontinue\n\t\t}\n\t\tqv, err := pquads.UnmarshalValue(p.Value)\n\t\tif err != nil {\n\t\t\tlast = err\n\t\t\tcontinue","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/kv/quadstore.go#L305-L341","documentation":"ValuesOf converts graph.Ref values into this quadstore's internal primitive IDs; it only understands refs it recognizes (proto.Primitive, integer-backed refs, etc.). Any other graph.Ref implementation cannot be resolved to stored values, so the store returns this error naming the unexpected value. It signals that a caller passed a Ref produced by a different quadstore or constructed ad hoc.","triggerScenarios":"Calling QuadStore.NameOf or QuadStore.ValuesOf with a graph.Ref that is not a type this kv quadstore understands (e.g. a *quad.IRI/wrapped ref from another backend, or a BNode ref) instead of the *proto.Primitive refs it returns from its own iterators.","commonSituations":"Mixing results from two different quadstore backends; caching graph.Ref values across store instances or process restarts where integers were expected; passing literals/IRIs directly instead of resolving them first.","solutions":["Only pass graph.Ref values obtained from this same QuadStore instance (e.g. from its iterators or NameOf results)","Convert quad.Value to a store ref via the store's resolution APIs before calling ValuesOf","Check the concrete type of the ref before calling: it must be *proto.Primitive or the integer-ref variants this store emits","Re-create refs after reopening the store instead of persisting them"],"exampleFix":"// before\nname, err := qs.NameOf(quad.RefOf(quad.IRI(\"http://example.org/alice\")))\n// after\nrefs, err := qs.ValueOf(ctx, quad.IRI(\"http://example.org/alice\"))\nif err != nil { return err }\nname, err := qs.NameOf(refs)","handlingStrategy":"type-guard","validationCode":"func isKVRef(r graph.Ref) bool {\n    switch r.(type) {\n    case *proto.Primitive:\n        return true\n    default:\n        return false\n    }\n}","typeGuard":"func isKVStoreRef(r graph.Ref) bool {\n    _, ok := r.(*proto.Primitive)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Never persist graph.Ref values across store restarts or backends","Obtain refs only from the same QuadStore instance's iterators","Re-resolve quad.Value to refs via the store's own APIs before lookups"],"tags":["graph-ref","type-mismatch","quadstore"],"backgroundTag":"incompatible-source-type","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}