DocsGPT icon indicating copy to clipboard operation
DocsGPT copied to clipboard

🐛 Bug Report: CrawlerLoader ignores allow_subdomains=False and includes subdomains

Open SiddharthCh7 opened this issue 1 month ago • 4 comments

📜 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:

  1. allow_subdomains=False does not work: Under the exact domain check (if link_base == base_domain:), docs.docsgpt.cloud is reduced to docsgpt.cloud, which matches docsgpt.cloud. The crawler follows subdomains even when explicitly told not to.

  2. Subdomain seeds leak across sibling subdomains: If the seed URL is https://docs.docsgpt.cloud, _get_base_domain() resolves to docsgpt.cloud. The crawler will traverse app.docsgpt.cloud, docsgpt.cloud, and any other sibling subdomains.

  3. Dead code: In line 165, link_base.endswith("." + base_domain) is unreachable because link_base never 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

Image

💻 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 avatar Oct 22 '26 14:10 SiddharthCh7

@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.

arc53-machine avatar Oct 22 '26 14:10 arc53-machine

Hi maintainers, I'm interested in working on this issue and would like to contribute. Could you assign it to me? Thanks!

abhiqnhi1731 avatar Oct 22 '26 18:10 abhiqnhi1731

@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.

arc53-machine avatar Oct 22 '26 18:10 arc53-machine

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.

ManishMadan2882 avatar Oct 28 '26 14:10 ManishMadan2882