cayleygraph/cayley · error
not found: %v
Error message
not found: %v
What it means
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.
Source
Thrown at graph/refs/refs.go:170
if err != nil {
return nil, err
}
}
return out, nil
}
func RefsOf(ctx context.Context, qs Namer, nodes []quad.Value) ([]Ref, error) {
if bq, ok := qs.(BatchNamer); ok {
return bq.RefsOf(ctx, nodes)
}
values := make([]Ref, len(nodes))
for i, node := range nodes {
value, err := qs.ValueOf(node)
if err != nil {
return nil, err
}
if value == nil {
return nil, fmt.Errorf("not found: %v", node)
}
values[i] = value
}
return values, nil
}
View on GitHub (pinned to 81dcd7d73e)
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
Example fix
// before
refs, err := graph.RefsOf(qs, nodes) // fails if any node is missing
// after
var known []graph.Value
for _, n := range nodes {
if v, err := qs.ValueOf(n); err == nil && v != nil {
known = append(known, n)
}
}
refs, err := graph.RefsOf(qs, known) Defensive patterns
Strategy: validation
Validate before calling
var known []graph.Value
for _, n := range nodes {
if v, err := qs.ValueOf(n); err != nil { return err } else if v != nil { known = append(known, n) }
} Type guard
func nodeExists(qs graph.QuadStore, n graph.Value) bool {
v, err := qs.ValueOf(n)
return err == nil && v != nil
} Try / catch
refs, err := graph.RefsOf(qs, nodes)
if err != nil && strings.HasPrefix(err.Error(), "not found:") {
// re-filter the list and retry, or skip the missing node
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Iterating a cached list of node values after data was deleted; passing user-supplied node strings that were never inserted; cross-store lookups.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- ErrDatabaseExists
- ErrNotInitialized
- ErrQuadExists
- ErrQuadNotExist
- unknown type of graph.Ref; not meant for this quadstore. app
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/ceae84779dac4222.
Report an issue: GitHub.