projectdiscovery/katana · error
failed to find shortest path
Error message
failed to find shortest path
What it means
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.
Source
Thrown at pkg/engine/headless/crawler/state.go:310
actions, err := c.crawlGraph.ShortestPath(currentPageHash, action.OriginID)
if err != nil {
if errors.Is(err, graphlib.ErrTargetNotReachable) {
c.logger.Debug("Target not reachable, reaching from blank state",
slog.String("action_origin_id", action.OriginID),
slog.String("current_page_hash", currentPageHash),
)
actions, err = c.crawlGraph.ShortestPath(emptyPageHash, action.OriginID)
if err != nil {
return "", errors.Wrap(err, "could not find path to origin page")
}
} else {
return "", errors.Wrap(err, "failed to find shortest path")
}
}View on GitHub (pinned to e3e742739c)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pkg/engine/headless/crawler/state.go:310 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/832b5b17f2d0fd0c.
Report an issue: GitHub.