🐛 Bug Report: CrawlerLoader ignores allow_subdomains=False and includes subdomains
📜 Description
In docsgpt/parser/remote/crawler_markdown.py, CrawlerLoader ignores allow_subdomains=False due to how domains are reconstructed in _get_base_domain() and _filter_links().
In lines 143–145 and 160–161:
extracted = _extract(parsed_link.netloc)
link_base = f"{extracted.domain}.{extracted.suffix}"
tldextract parses hostnames into (subdomain, domain, suffix). By omitting extracted.subdomain, link_base always resolves strictly to the registered domain (e.g. docsgpt.cloud instead of docs.docsgpt.cloud).
Because of this:
-
allow_subdomains=Falsedoes not work: Under the exact domain check (if link_base == base_domain:),docs.docsgpt.cloudis reduced todocsgpt.cloud, which matchesdocsgpt.cloud. The crawler follows subdomains even when explicitly told not to. -
Subdomain seeds leak across sibling subdomains: If the seed URL is
https://docs.docsgpt.cloud,_get_base_domain()resolves todocsgpt.cloud. The crawler will traverseapp.docsgpt.cloud,docsgpt.cloud, and any other sibling subdomains. -
Dead code: In line 165,
link_base.endswith("." + base_domain)is unreachable becauselink_basenever contains subdomains or a leading dot.
👟 Reproduction steps
Run the following minimal script:
from docsgpt.parser.remote.crawler_markdown import CrawlerLoader
# Initialize crawler with allow_subdomains=False
loader = CrawlerLoader(allow_subdomains=False)
base = loader._get_base_domain("https://docsgpt.cloud")
links = [
("https://docsgpt.cloud/about", "About Page"),
("https://docs.docsgpt.cloud/Deploying", "Docs Subdomain"),
("https://app.docsgpt.cloud/login", "App Subdomain"),
("https://github.com/arc53/DocsGPT", "External Link"),
]
filtered = loader._filter_links(links, base)
print(f"Base Domain: {base}")
print(f"allow_subdomains: {loader.allow_subdomains}\n")
print("Filtered Links:")
for link in filtered:
print(f" - {link}")
👍 Expected behavior
Base Domain: docsgpt.cloud
allow_subdomains: False
Filtered Links:
- https://docsgpt.cloud/about
👎 Actual Behavior with Screenshots
💻 Operating system
MacOS
What browsers are you seeing the problem on?
No response
🤖 What development environment are you experiencing this bug on?
Local dev server
🔒 Did you set the correct environment variables in the right path? List the environment variable names (not values please!)
No response
📃 Provide any additional context for the Bug.
No response
📖 Relevant log output
Base Domain: docsgpt.cloud
allow_subdomains: False
Filtered Links:
- https://docsgpt.cloud/about
- https://docs.docsgpt.cloud/Deploying
- https://app.docsgpt.cloud/login
👀 Have you spent some time to check if this bug has been raised before?
- [x] I checked and didn't find similar issue
🔗 Are you willing to submit PR?
Yes, I am willing to submit a PR!
🧑⚖️ Code of Conduct
- [x] I agree to follow this project's Code of Conduct
@SiddharthCh7, you're assigned.
- Open a PR or post progress within 14 days; otherwise, the issue goes back to other contributors.
- Read
CONTRIBUTING.md. - Include regression tests for exact-host filtering and subdomain seeds, plus a screenshot or short recording of the corrected output in the PR.
Automated triage. A maintainer will follow up.
Hi maintainers, I'm interested in working on this issue and would like to contribute. Could you assign it to me? Thanks!
@abhiqnhi1731, PR #3148 already addresses this issue, and @SiddharthCh7 is assigned. You can help by reviewing the PR or testing exact-host filtering and subdomain seeds.
Automated triage. A maintainer will follow up.
Fixed on main. The host filtering moved out of the crawler: crawler_markdown.py is gone and the decision now sits in SiteScope._host_ok in website_loader.py, which requires an exact host match unless include_subdomains is on, and compares registered domains when it is. So a docs.docsgpt.cloud seed no longer accepts other subdomains.
Your diagnosis was right, the old code reduced the seed to domain.suffix and then treated that as an exact match. Thanks for the report.