{"record":{"id":"ceae84779dac4222","repo":"cayleygraph/cayley","slug":"not-found-v","errorCode":null,"errorMessage":"not found: %v","messagePattern":"not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/refs/refs.go","lineNumber":170,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn out, nil\n}\n\nfunc RefsOf(ctx context.Context, qs Namer, nodes []quad.Value) ([]Ref, error) {\n\tif bq, ok := qs.(BatchNamer); ok {\n\t\treturn bq.RefsOf(ctx, nodes)\n\t}\n\tvalues := make([]Ref, len(nodes))\n\tfor i, node := range nodes {\n\t\tvalue, err := qs.ValueOf(node)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif value == nil {\n\t\t\treturn nil, fmt.Errorf(\"not found: %v\", node)\n\t\t}\n\t\tvalues[i] = value\n\t}\n\treturn values, nil\n}\n","sourceCodeStart":152,"sourceCodeEnd":176,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/refs/refs.go#L152-L176","documentation":"RefsOf resolves a batch of node values to refs by calling ValueOf for each. If ValueOf returns nil refs for a node — meaning the node does not exist in the store — RefsOf fails hard with \"not found: %v\" rather than inserting a nil entry.","triggerScenarios":"Calling graph.RefsOf(qs, nodes) with any node value absent from the QuadStore (deleted node, typo'd/never-written value, stale cached value from another store).","commonSituations":"Iterating a cached list of node values after data was deleted; passing user-supplied node strings that were never inserted; cross-store lookups.","solutions":["Call qs.ValueOf(node) per node first and skip nil results before batch-calling RefsOf","Verify the node exists (e.g. via NameOf round-trip or an iterator contains check)","Reload/refresh the node list from the same store that RefsOf will query","Handle the returned error and filter out the missing node, then retry the batch"],"exampleFix":"// before\nrefs, err := graph.RefsOf(qs, nodes) // fails if any node is missing\n// after\nvar known []graph.Value\nfor _, n := range nodes {\n    if v, err := qs.ValueOf(n); err == nil && v != nil {\n        known = append(known, n)\n    }\n}\nrefs, err := graph.RefsOf(qs, known)","handlingStrategy":"validation","validationCode":"var known []graph.Value\nfor _, n := range nodes {\n    if v, err := qs.ValueOf(n); err != nil { return err } else if v != nil { known = append(known, n) }\n}","typeGuard":"func nodeExists(qs graph.QuadStore, n graph.Value) bool {\n    v, err := qs.ValueOf(n)\n    return err == nil && v != nil\n}","tryCatchPattern":"refs, err := graph.RefsOf(qs, nodes)\nif err != nil && strings.HasPrefix(err.Error(), \"not found:\") {\n    // re-filter the list and retry, or skip the missing node\n}","preventionTips":["Re-derive node lists from the same store right before use","Filter out nil results from ValueOf before batching","Avoid caching graph.Value across store rebuilds","Treat user-supplied node names as possibly nonexistent"],"tags":["refs","entity-not-found","quadstore"],"backgroundTag":"entity-not-found","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"}