Skip to content

feat(crawlers): implement Request.skip_navigation to skip navigation and run the handler directly - #2338

Open
enriquealonso01 wants to merge 1 commit into
apify:masterfrom
enriquealonso01:fix/skip-navigation-2311
Open

enriquealonso01 wants to merge 1 commit into
apify:masterfrom
enriquealonso01:fix/skip-navigation-2311

Conversation

@enriquealonso01

Copy link
Copy Markdown

Fixes #2311

CrawleeRequestData.skip_navigation was declared, persisted and serialized as skipNavigation, but nothing in src/crawlee read it — setting it had no effect.

This implements the flag with the same semantics as JS SDK v4 (apify/crawlee#3107, apify/crawlee#3381), per janbuchar's direction in the issue:

  • When request.skip_navigation is True, BasicCrawler bypasses the context pipeline (whose middlewares perform the navigation) and invokes the request handler directly.
  • The navigation-only request.loaded_url member raises the new public NavigationSkippedError instead of returning None.
  • Since no navigation happens, response/parsed-content members never exist in the context — use BasicCrawler-level helpers (push_data, add_requests, send_request) instead.

Not breaking: the flag's storage format is unchanged, and accessing navigation-only members of a plain (navigated) context behaves exactly as before.

Testing

  • New end-to-end + serialization tests: 2/2 pass
  • tests/unit/crawlers: 590 passed, 1 skipped; the only 2 failures (parsel xhtml-as-xml, playwright firefox headless) fail identically on clean master (stash-verified, pre-existing)
  • tests/unit/test_request.py: 4/4 pass
  • ruff check + ruff format clean on all touched files

…and run the handler directly

Implements the previously unused `skip_navigation` flag (apify#2311): when set,
BasicCrawler bypasses the context pipeline (whose middlewares perform the
navigation) and invokes the request handler directly. Accessing the
navigation-only `request.loaded_url` member raises the new public
`NavigationSkippedError`, mirroring the JS SDK behavior (apify/crawlee
#3107, #3381).

- add public `NavigationSkippedError` to crawlee.errors
- add `Request.skip_navigation` property backed by CrawleeRequestData
  (persisted/serialized via the existing `skipNavigation` alias)
- BasicCrawler: route skip-navigation requests around the context pipeline
- regression tests for end-to-end behavior and serialization roundtrip
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement or remove the unused Request.skip_navigation flag

2 participants