projectdiscovery/katana · info

ErrMaxDepthReached

ErrMaxDepthReached

Error message

max depth reached

What it means

ErrMaxDepthReached is a sentinel error returned when a request's Depth exceeds Options.MaxDepth. The URL is output with this error (so users can see why it was skipped) and is not enqueued for crawling. It is a normal termination condition of depth-limited crawling, not a bug.

Source

Thrown at pkg/engine/common/error.go:6

package common

import "errors"

var ErrOutOfScope = errors.New("out of scope")
var ErrMaxDepthReached = errors.New("max depth reached")

View on GitHub (pinned to e3e742739c)

Solutions

  1. Increase MaxDepth (katana -depth 10) if deeper crawling is required
  2. Filter results whose Error equals common.ErrMaxDepthReached.Error() if only successfully visited URLs matter
  3. Accept the behavior: URLs skipped by depth may still be visited later via a shorter path, by design

Example fix

// before: default shallow crawl missing deep pages
opts.MaxDepth = 3
// after
opts.MaxDepth = 10 // raise depth for deep sites
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(targetURL)
if err != nil { return err }
if expectedDepth(u) > opts.MaxDepth {
    opts.MaxDepth = expectedDepth(u) // raise before enqueue
}

Type guard

func isDepthSkipped(result *output.Result) bool {
    return result != nil && result.Error == common.ErrMaxDepthReached.Error()
}

Try / catch

if result.Error == common.ErrMaxDepthReached.Error() {
    log.Debugf("skipped (depth): %s", result.Request.URL)
    return nil
}

Prevention

When it happens

Trigger: In Enqueue (pkg/engine/common/base.go:132) when nr.Depth > s.Options.Options.MaxDepth; typically links found on pages already at MaxDepth that would push traversal one level deeper.

Common situations: Running katana with the default -d/--depth limit (e.g. depth 3) on deep sites and wondering why deep URLs appear in output with 'max depth reached'; forgetting to raise --depth when full coverage is needed.

Related errors


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