cayleygraph/cayley · error
not implemented: need a function from predicates to their as
Error message
not implemented: need a function from predicates to their associated edges
What it means
predicatesMorphism() has no Reversal: reversing it would require a function mapping predicates to their associated edges, which the path layer does not provide. Evaluating a path in reverse that contains the predicates step panics with this message.
Source
Thrown at query/path/morphism_apply_functions.go:224
// labelsMorphism iterates to the uniqified set of labels from
// the given set of nodes in the path.
func labelsMorphism() morphism {
return morphism{
Reversal: func(ctx *pathContext) (morphism, *pathContext) {
panic("not implemented")
},
Apply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {
return shape.Labels(in), ctx
},
}
}
// predicatesMorphism iterates to the uniqified set of predicates from
// the given set of nodes in the path.
func predicatesMorphism(isIn bool) morphism {
return morphism{
Reversal: func(ctx *pathContext) (morphism, *pathContext) {
panic("not implemented: need a function from predicates to their associated edges")
},
Apply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {
return shape.Predicates(in, isIn), ctx
},
}
}
// savePredicatesMorphism tags either forward or reverse predicates from current node
// without affecting path.
func savePredicatesMorphism(isIn bool, tag string) morphism {
return morphism{
Reversal: func(ctx *pathContext) (morphism, *pathContext) {
return savePredicatesMorphism(isIn, tag), ctx
},
Apply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {
return shape.SavePredicates(in, isIn, tag), ctx
},
}View on GitHub (pinned to 81dcd7d73e)
Solutions
- Restructure the query so the predicates step is only applied forward.
- Replace predicates() with an explicit traversal over predicate edges that supports reversal.
- If you own the code, implement Reversal by deriving the edge set from predicates.
Example fix
// before p := cayley.StartPath(qs).Predicates(true) // later reversed via Back() -> panic // after: keep predicates forward-only or use explicit edge traversal p := cayley.StartPath(qs).Out(predQuad.Predicate)...
Defensive patterns
Strategy: type-guard
Validate before calling
if pathWillBeReversed && pathContainsPredicatesStep {
return errors.New("predicates() step cannot be reversed; restructure the query")
} Prevention
- Keep predicates() forward-only.
- Express reverse needs via explicit edge traversals.
- recover() around path building.
When it happens
Trigger: A reversed/backtracking traversal that includes predicates()/Predicates(in, isIn), forcing evaluation of the morphism's Reversal function.
Common situations: Gremlin-style queries like Predicates(true) used within Back() or reverse evaluation; converting old Cayley gremlin code where the predicates step appears on the reverse side.
Related errors
- not implemented
- did not pass a string predicate or a Path to FollowRecursive
- Building an iterator from a morphism. Bind a QuadStore with
- ErrEmptyPath
- error updating node: %v
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/97af6491bc2e38b0.
Report an issue: GitHub.