{"record":{"id":"ea6c462b1ee2fed5","repo":"projectdiscovery/katana","slug":"could-not-add-edge-to-graph-source-vertex-s","errorCode":null,"errorMessage":"could not add edge to graph: source vertex %s","messagePattern":"could not add edge to graph: source vertex (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/engine/headless/graph/graph.go","lineNumber":79,"sourceCode":"\tif n.NavigationAction != nil {\n\t\tedgeAttrs := map[string]string{\n\t\t\t\"label\": n.NavigationAction.String(),\n\t\t}\n\n\t\terr = g.graph.AddEdge(n.OriginID, n.UniqueID, func(ep *graph.EdgeProperties) {\n\t\t\tep.Weight = n.Depth\n\t\t\tep.Attributes = edgeAttrs\n\t\t})\n\t\tif err != nil {\n\t\t\tif errors.Is(err, graph.ErrEdgeAlreadyExists) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn errors.Wrapf(err, \"could not add edge to graph: source vertex %s\", n.OriginID)\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/engine/headless/graph/graph.go#L61-L97","documentation":"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.","triggerScenarios":"Thrown at pkg/engine/headless/graph/graph.go:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the origin page state (n.OriginID) was added as a vertex before adding the edge","Ignore only ErrEdgeAlreadyExists; any other cause (missing vertex, invalid IDs) must be fixed upstream","Log n.OriginID and n.UniqueID to find which endpoint is absent from the graph","Ensure page states are always registered via AddPageState in traversal order"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e3e742739c3746f085943ce918fb4e2b8daf6fe6","analyzedAt":"2026-09-03T14:55:13.248Z","contentChangedAt":"2026-09-03T14:55:13.248Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}