fix: Filter sitemap-derived URLs by enqueue strategy#1864
Merged
Conversation
5976063 to
a4317a4
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1864 +/- ##
==========================================
+ Coverage 92.42% 92.53% +0.10%
==========================================
Files 158 158
Lines 11027 11078 +51
==========================================
+ Hits 10192 10251 +59
+ Misses 835 827 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a4317a4 to
22cb16b
Compare
22cb16b to
cfc66d9
Compare
Mantisus
suggested changes
Apr 30, 2026
Collaborator
Mantisus
left a comment
There was a problem hiding this comment.
Just one note about parsing URLs. Everything else is LGTM.
6b437b1 to
d785f08
Compare
janbuchar
reviewed
May 4, 2026
The wrapper added nothing beyond a debug log that didn't affect control flow, since `matches_enqueue_strategy` already returns `False` when either host is missing. Replace the two callsites with direct calls to the shared helper and drop the now-unused `EnqueueStrategy` import.
d785f08 to
610ae46
Compare
janbuchar
approved these changes
May 4, 2026
4ba08d1 to
6f4d940
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SitemapRequestLoaderaccepted every<loc>it parsed (including nested sitemaps androbots.txtdirectives) without checking the host, so a sitemap could push arbitrary URLs into the queue. This wires the existingEnqueueStrategymechanism into the sitemap loader and therobots.txtdiscovery path.What changed
SitemapRequestLoader.__init__gainsenqueue_strategy: EnqueueStrategy = 'same-hostname', applied to nested<sitemap><loc>and<urlset><url><loc>entries against the parent sitemap URL. Pass'all'to opt out. The strategy is stamped on emittedRequests, soBasicCrawler._check_url_after_redirectscontinues policing across redirects.RobotsTxtFile.get_sitemaps(*, enqueue_strategy)filters cross-hostSitemap:directives (already disallowed by spec). Thediscover_valid_sitemapspath is closed as well.crawlee._utils.urls.matches_enqueue_strategyso request loaders andBasicCrawlershare one implementation.BasicCrawlernow usesyarl.URLto match the rest of the codebase.same-domainso it isn't re-run per URL on hot paths.Behavior change
The new default
'same-hostname'matchesenqueue_links. Callers depending on cross-host sitemap entries must passenqueue_strategy='all'(or'same-domain').RobotsTxtFile.get_sitemaps()no longer returns cross-host entries; its tests were rewritten to assert filtering, with a newtest_extract_same_host_sitemaps_urlscovering the legitimate path.