projectdiscovery/katana · error

could not add edge to graph: source vertex %s

Error message

could not add edge to graph: source vertex %s

What it means

AddPageState fails while linking the new page state to its origin: graph.AddEdge(n.OriginID, n.UniqueID, ...) returned an error other than graph.ErrEdgeAlreadyExists (treated as success). Most commonly the origin vertex does not exist in the graph (ErrEdgeCreatesCycle/ErrVertexNotFound), so the navigation edge cannot be recorded; the source vertex ID is embedded in the message.

Source

Thrown at pkg/engine/headless/graph/graph.go:79

	if n.NavigationAction != nil {
		edgeAttrs := map[string]string{
			"label": n.NavigationAction.String(),
		}

		err = g.graph.AddEdge(n.OriginID, n.UniqueID, func(ep *graph.EdgeProperties) {
			ep.Weight = n.Depth
			ep.Attributes = edgeAttrs
		})
		if err != nil {
			if errors.Is(err, graph.ErrEdgeAlreadyExists) {
				return nil
			}
			return errors.Wrapf(err, "could not add edge to graph: source vertex %s", n.OriginID)
		}
	}
	return nil
}

View on GitHub (pinned to e3e742739c)

Solutions

  1. Check that the origin page state (n.OriginID) was added as a vertex before adding the edge
  2. Ignore only ErrEdgeAlreadyExists; any other cause (missing vertex, invalid IDs) must be fixed upstream
  3. Log n.OriginID and n.UniqueID to find which endpoint is absent from the graph
  4. Ensure page states are always registered via AddPageState in traversal order
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/engine/headless/graph/graph.go:79 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of projectdiscovery/katana@e3e742739c (2026-09-03). Data as JSON: /api/errors/ea6c462b1ee2fed5. Report an issue: GitHub.