fix(deep-crawling): allow single-label hostnames in can_process_url validation - #2143
Open
Bruce-Yii wants to merge 1 commit into
Open
fix(deep-crawling): allow single-label hostnames in can_process_url validation#2143Bruce-Yii wants to merge 1 commit into
Bruce-Yii wants to merge 1 commit into
Conversation
…alidation BFSDeepCrawlStrategy and BestFirstCrawlingStrategy rejected any URL whose netloc contains no dot, which dropped valid internal targets such as intranet hosts, localhost (with or without a port) and Docker service names. Scheme and netloc checks remain; only the dot heuristic is removed. Fixes unclecode#2079
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
Fixes #2079
BFSDeepCrawlStrategy.can_process_url()andBestFirstCrawlingStrategy.can_process_url()rejected any URL whose netloc contains no dot (Invalid domain), silently dropping valid internal targets such as intranet hosts,localhost(with or without a port) and Docker service names during deep crawls. The error was raised before the configuredFilterChainwas ever applied.The scheme (
http/https) and non-empty netloc checks are kept; only the dot heuristic is removed, sohttps://name/xyznow passes validation and reaches the filter chain.List of files changed and why
crawl4ai/deep_crawling/bfs_strategy.py- Remove the dot requirement from URL validation incan_process_url.crawl4ai/deep_crawling/bff_strategy.py- Same fix for the best-first strategy.tests/deep_crawling/test_can_process_url.py- New parametrized tests covering single-label hosts, localhost with port, IP literals, rejection of missing scheme/netloc and non-http(s) schemes, and filter-chain behavior at depth > 0.How Has This Been Tested?
pytest tests/deep_crawling/test_can_process_url.py -v→ 18 passedpytest tests/deep_crawling/→ 85 passed; the 2 failures intest_deep_crawl_resume_integration.pyare pre-existing environment issues (they require launching a real Playwright Chromium, which is not available in this dev venv) and fail identically on unmodifieddevelopruff check --select E9,F63,F7,F82on the changed files → cleanpython -m py_compileon the changed files → cleanChecklist: