cayleygraph/cayley · error

not implemented

Error message

not implemented

What it means

labelsMorphism() defines a path morphism whose Reversal is unimplemented; evaluating the reverse traversal panics with 'not implemented'. Forward application simply maps the shape via shape.Labels, but Cayley cannot reverse the labels step.

Source

Thrown at query/path/morphism_apply_functions.go:211

			out := ctx.copy()
			ctx.labelSet = path
			return labelContextMorphism(tags, via...), &out
		},
		Apply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {
			out := ctx.copy()
			out.labelSet = path
			return in, &out
		},
		tags: tags,
	}
}

// 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
		},
	}

View on GitHub (pinned to 81dcd7d73e)

Solutions

  1. Restructure the query so labels() is only applied forward and never reversed.
  2. Replace labels() with an equivalent explicit traversal that supports reversal.
  3. If maintaining a fork, implement the Reversal function to undo shape.Labels.

Example fix

// before: labels() used inside a reversed path
m := cayley.StartMorphism().Labels() // reversed later -> panic
// after: keep the labels step forward-only
results := cayley.NewPath(qs).Out(pred).Labels()...
Defensive patterns

Strategy: type-guard

Validate before calling

if pathWillBeReversed && pathContainsLabelsStep {
    return errors.New("labels() step cannot be reversed; restructure the query")
}

Prevention

When it happens

Trigger: A reversed/backtracking traversal that includes the labels() step, forcing evaluation of the morphism's Reversal function (e.g. via Back() or reverse path evaluation).

Common situations: Gremlin-style queries using labels() inside a context that requires reversal; ported legacy code where the labels step lands on the reverse side of a path.

Related errors


AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06). Data as JSON: /api/errors/9cbf9af48dd8bbeb. Report an issue: GitHub.