{"record":{"id":"97af6491bc2e38b0","repo":"cayleygraph/cayley","slug":"not-implemented-need-a-function-from-predicates-t","errorCode":null,"errorMessage":"not implemented: need a function from predicates to their associated edges","messagePattern":"not implemented: need a function from predicates to their associated edges","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/path/morphism_apply_functions.go","lineNumber":224,"sourceCode":"// labelsMorphism iterates to the uniqified set of labels from\n// the given set of nodes in the path.\nfunc labelsMorphism() morphism {\n\treturn morphism{\n\t\tReversal: func(ctx *pathContext) (morphism, *pathContext) {\n\t\t\tpanic(\"not implemented\")\n\t\t},\n\t\tApply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {\n\t\t\treturn shape.Labels(in), ctx\n\t\t},\n\t}\n}\n\n// predicatesMorphism iterates to the uniqified set of predicates from\n// the given set of nodes in the path.\nfunc predicatesMorphism(isIn bool) morphism {\n\treturn morphism{\n\t\tReversal: func(ctx *pathContext) (morphism, *pathContext) {\n\t\t\tpanic(\"not implemented: need a function from predicates to their associated edges\")\n\t\t},\n\t\tApply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {\n\t\t\treturn shape.Predicates(in, isIn), ctx\n\t\t},\n\t}\n}\n\n// savePredicatesMorphism tags either forward or reverse predicates from current node\n// without affecting path.\nfunc savePredicatesMorphism(isIn bool, tag string) morphism {\n\treturn morphism{\n\t\tReversal: func(ctx *pathContext) (morphism, *pathContext) {\n\t\t\treturn savePredicatesMorphism(isIn, tag), ctx\n\t\t},\n\t\tApply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {\n\t\t\treturn shape.SavePredicates(in, isIn, tag), ctx\n\t\t},\n\t}","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/path/morphism_apply_functions.go#L206-L242","documentation":"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.","triggerScenarios":"A reversed/backtracking traversal that includes predicates()/Predicates(in, isIn), forcing evaluation of the morphism's Reversal function.","commonSituations":"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.","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."],"exampleFix":"// before\np := cayley.StartPath(qs).Predicates(true) // later reversed via Back() -> panic\n// after: keep predicates forward-only or use explicit edge traversal\np := cayley.StartPath(qs).Out(predQuad.Predicate)...","handlingStrategy":"type-guard","validationCode":"if pathWillBeReversed && pathContainsPredicatesStep {\n    return errors.New(\"predicates() step cannot be reversed; restructure the query\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep predicates() forward-only.","Express reverse needs via explicit edge traversals.","recover() around path building."],"tags":["panic","path","morphism","cayley","gremlin"],"backgroundTag":"method-not-implemented","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"}