projectdiscovery/katana · info
ErrOutOfScope
ErrOutOfScope
Error message
out of scope
What it means
ErrOutOfScope is a sentinel error in katana's common engine package indicating a request was not visited because its URL falls outside the configured crawl scope. Instead of being enqueued, out-of-scope requests are sent directly to output with this error attached. It signals intentional filtering, not a runtime failure.
Source
Thrown at pkg/engine/common/error.go:5
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
- Verify the URL is genuinely out of scope; if it should be crawled, widen scope with -d / -c / scope filters or use 'in-scope' regex options
- Set Options.Options.DisplayOutScope only when diagnostics on skipped URLs are desired
- Compare the error against common.ErrOutOfScope (errors.Is) to filter it from real failures in custom output writers
Example fix
// before: treating every writer error as fatal
if result.Error != "" { return fmt.Errorf("crawl failed: %s", result.Error) }
// after
if errors.Is(err, common.ErrOutOfScope) { return nil } // expected scope filtering Defensive patterns
Strategy: type-guard
Validate before calling
u, err := url.Parse(targetURL)
if err != nil { return err }
if !scopeMatcher.Match(u) { // pre-check against scope regexes
return nil // skip before Enqueue
} Type guard
func isOutOfScope(err error) bool { return errors.Is(err, common.ErrOutOfScope) } Try / catch
if result.Error != "" {
if errors.Is(err, common.ErrOutOfScope) {
return nil // expected, ignore
}
return err
} Prevention
- Align scope flags (-d, scope filters) with the domains you expect to crawl
- Use --display-out-scope only for diagnostics
- Always compare with errors.Is/== against the sentinel, never string-match generic errors
When it happens
Trigger: Enqueue receives a request whose URL does not match the scope rules (-d domain, scope filters, field-scope); with Options.DisplayOutScope set, the request is passed to s.Output(nr, nil, ErrOutOfScope) at pkg/engine/common/base.go:160 and skipped from the queue.
Common situations: Crawling with -d example.com and encountering links to cdn.example.org or third-party sites; using a custom scope filter that is stricter than expected; enabling display-out-scope and mistaking these output entries for crawl errors.
Related errors
- ErrMaxDepthReached
- ErrNoCrawlingAction
- unknown action type: %v
- failed to get origin page state: %w
- failed to navigate back to origin page: %s != %s
AI-assisted analysis of projectdiscovery/katana@e3e742739c (2026-09-03).
Data as JSON: /api/errors/75217d1f8720dd2c.
Report an issue: GitHub.