projectdiscovery/katana · error

could not add vertex to graph

Error message

could not add vertex to graph

What it means

CrawlGraph.AddPageState fails when the underlying graph library rejects the AddVertex call with an error other than graph.ErrVertexAlreadyExists (which is silently accepted as a no-op). Any other failure means the page-state vertex could not be inserted, corrupting the crawl graph for later navigation.

Source

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

err := g.graph.AddVertex(n, func(vp *graph.VertexProperties) {
		vp.Weight = n.Depth
		vp.Attributes = vertexAttrs
	})
	if err != nil {
		if errors.Is(err, graph.ErrVertexAlreadyExists) {
			return nil
		}
		return errors.Wrap(err, "could not add vertex to graph")
	}

View on GitHub (pinned to e3e742739c)

Solutions

  1. Inspect the wrapped graph error; ErrVertexAlreadyExists is already handled as success
  2. Verify the PageState value and its hash ID are valid before insertion
  3. Ensure concurrent AddPageState calls are serialized if the graph is not thread-safe
  4. Fail the crawl action so the inconsistent graph state is not silently propagated
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/engine/headless/graph/graph.go:63 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/c6957f101c8121d6. Report an issue: GitHub.