{"record":{"id":"832b5b17f2d0fd0c","repo":"projectdiscovery/katana","slug":"failed-to-find-shortest-path","errorCode":null,"errorMessage":"failed to find shortest path","messagePattern":"failed to find shortest path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/engine/headless/crawler/state.go","lineNumber":310,"sourceCode":"\tactions, err := c.crawlGraph.ShortestPath(currentPageHash, action.OriginID)\n\tif err != nil {\n\t\tif errors.Is(err, graphlib.ErrTargetNotReachable) {\n\t\t\tc.logger.Debug(\"Target not reachable, reaching from blank state\",\n\t\t\t\tslog.String(\"action_origin_id\", action.OriginID),\n\t\t\t\tslog.String(\"current_page_hash\", currentPageHash),\n\t\t\t)\n\n\t\t\tactions, err = c.crawlGraph.ShortestPath(emptyPageHash, action.OriginID)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", errors.Wrap(err, \"could not find path to origin page\")\n\t\t\t}\n\t\t} else {\n\t\t\treturn \"\", errors.Wrap(err, \"failed to find shortest path\")\n\t\t}\n\t}","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/engine/headless/crawler/state.go#L292-L328","documentation":"tryShortestPathNavigation fails when crawlGraph.ShortestPath(currentPageHash, action.OriginID) returns an error other than graphlib.ErrTargetNotReachable — i.e. an unexpected graph failure (e.g. source vertex missing, internal graph error) rather than a merely unreachable target, so the back-navigation cannot be planned.","triggerScenarios":"Thrown at pkg/engine/headless/crawler/state.go:310 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error; a missing source vertex means currentPageHash was never added to the crawl graph","Ensure every visited page state is registered via AddPageState before back-navigation","Log currentPageHash and action.OriginID to diagnose vertex existence","Skip the back-navigation and mark the action as non-replayable for this run"],"exampleFix":null,"handlingStrategy":"fallback","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"}