Conversation
parseRobotsTxt called robots.isAllowed(url) with no user-agent, so robots-parser evaluated only the `User-agent: *` group. A group naming OpenSEO-Audit was ignored in both directions: a site blocking the crawler was crawled anyway, and a site admitting it while disallowing `*` had its audit stop at the start URL.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Problem
The crawler introduces itself as
OpenSEO-Audit/1.0in every request, thenreads robots.txt as an anonymous agent:
robots-parser's
isAllowed(url, ua)falls back to theUser-agent: *groupwhen
uais omitted, so any group naming the crawler is dead text. That missesin both directions:
User-agent: OpenSEO-Audit / Disallow: /— iscrawled anyway.
User-agent: * / Disallow: /plus
User-agent: OpenSEO-Audit / Allow: /— is not crawled at all. This isthe one users hit:
parseRobotsTxtgates both the discovery seeding(
siteAuditWorkflowPhases) and the crawl frontier (shouldQueueCrawlLink),so the audit stops at the start URL and there is nothing on screen to explain
why.
Fix
Pass the crawler's own token to
isAllowed. robots-parser matches the producttoken out of
OpenSEO-Audit/1.0, so the same string the fetches send is theright argument. It was written inline in two places already, so it is now a
named constant in the file and the fetch headers read it too — same string, no
behaviour change there.
Tests
New
discovery.test.ts.parseRobotsTxtis exported, pure and deterministic,so no network or mocks are needed.
Two invariants for the defect and one pin: a robots.txt with only a
*groupmust behave exactly as before — that is what shows this is a more specific
match, not a widening. It passes before and after.
Against
main:With the fix:
How I tested
Windows 11, Node 22.
I did not run the whole suite or e2e.